]> git.proxmox.com Git - rustc.git/blob - vendor/gimli/fixtures/self/README.md
New upstream version 1.65.0+dfsg1
[rustc.git] / vendor / gimli / fixtures / self / README.md
1 # What are these files?
2
3 These files are the DWARF data generated for (an early version of) this
4 library. Each file corresponds is a section from the built library's object
5 file. By splitting the sections out to their own files, we don't need to worry
6 about cross platform and cross object file format issues when running examples.
7
8 # Updating and adding new sections
9
10 ## macOS
11
12 Use `otool` to list the sections of a binary:
13
14 ```
15 $ otool -l path/to/binary
16 ```
17
18 You should see output similar to this:
19
20 ```
21 Load command 0
22 cmd LC_SEGMENT_64
23 cmdsize 72
24 segname __PAGEZERO
25 vmaddr 0x0000000000000000
26 vmsize 0x0000000100000000
27 fileoff 0
28 filesize 0
29 maxprot 0x00000000
30 initprot 0x00000000
31 nsects 0
32 flags 0x0
33 Load command 1
34 cmd LC_SEGMENT_64
35 cmdsize 712
36 segname __TEXT
37 vmaddr 0x0000000100000000
38 vmsize 0x00000000001b7000
39 fileoff 0
40 filesize 1798144
41 maxprot 0x00000007
42 initprot 0x00000005
43 nsects 8
44 flags 0x0
45 Section
46 sectname __text
47 segname __TEXT
48 addr 0x0000000100000a50
49 size 0x0000000000170716
50 offset 2640
51 align 2^4 (16)
52 reloff 0
53 nreloc 0
54 flags 0x80000400
55 reserved1 0
56 reserved2 0
57 ```
58
59 Etc.
60
61 Find the `Section` entry of the section you'd like to isolate. For example, if
62 you're looking for `eh_frame`, find an entry like this:
63
64 ```
65 Section
66 sectname __eh_frame
67 segname __TEXT
68 addr 0x0000000100192f38
69 size 0x00000000000240c8
70 offset 1650488
71 align 2^3 (8)
72 reloff 0
73 nreloc 0
74 flags 0x00000000
75 reserved1 0
76 reserved2 0
77 ```
78
79 Then use `dd` to copy `size` bytes starting from `offset`:
80
81 ```
82 $ dd bs=1 skip=1650488 count=$(printf "%d" 0x00000000000240c8) if=path/to/binary of=fixtures/self/eh_frame
83 ```
84
85 Finally, use `otool` and `hexdump` to verify that the isolated section has the
86 same data as the section within the binary:
87
88 ```
89 $ otool -s __TEXT __eh_frame path/to/binary | head
90 path/to/binary:
91 Contents of (__TEXT,__eh_frame) section
92 0000000100192f38 14 00 00 00 00 00 00 00 01 7a 52 00 01 78 10 01
93 0000000100192f48 10 0c 07 08 90 01 00 00 24 00 00 00 1c 00 00 00
94 0000000100192f58 f8 da e6 ff ff ff ff ff 66 00 00 00 00 00 00 00
95 0000000100192f68 00 41 0e 10 86 02 43 0d 06 00 00 00 00 00 00 00
96 0000000100192f78 1c 00 00 00 00 00 00 00 01 7a 50 4c 52 00 01 78
97 0000000100192f88 10 07 9b 9d 40 02 00 10 10 0c 07 08 90 01 00 00
98 0000000100192f98 2c 00 00 00 24 00 00 00 20 db e6 ff ff ff ff ff
99 0000000100192fa8 8d 00 00 00 00 00 00 00 08 37 e7 fd ff ff ff ff
100
101 $ otool -s __TEXT __eh_frame path/to/binary | tail
102 00000001001b6f68 9a 0a 00 00 00 00 00 00 00 41 0e 10 86 02 43 0d
103 00000001001b6f78 06 50 83 07 8c 06 8d 05 8e 04 8f 03 00 00 00 00
104 00000001001b6f88 24 00 00 00 7c 0e 00 00 30 a0 fb ff ff ff ff ff
105 00000001001b6f98 15 00 00 00 00 00 00 00 00 41 0e 10 86 02 43 0d
106 00000001001b6fa8 06 00 00 00 00 00 00 00 24 00 00 00 a4 0e 00 00
107 00000001001b6fb8 28 a0 fb ff ff ff ff ff 1c 00 00 00 00 00 00 00
108 00000001001b6fc8 00 41 0e 10 86 02 43 0d 06 00 00 00 00 00 00 00
109 00000001001b6fd8 24 00 00 00 cc 0e 00 00 20 a0 fb ff ff ff ff ff
110 00000001001b6fe8 66 01 00 00 00 00 00 00 00 41 0e 10 86 02 43 0d
111 00000001001b6ff8 06 00 00 00 00 00 00 00
112 ```
113
114 This should be the same, ignoring the leading offsets:
115
116 ```
117 $ hexdump fixtures/self/eh_frame | head
118 0000000 14 00 00 00 00 00 00 00 01 7a 52 00 01 78 10 01
119 0000010 10 0c 07 08 90 01 00 00 24 00 00 00 1c 00 00 00
120 0000020 f8 da e6 ff ff ff ff ff 66 00 00 00 00 00 00 00
121 0000030 00 41 0e 10 86 02 43 0d 06 00 00 00 00 00 00 00
122 0000040 1c 00 00 00 00 00 00 00 01 7a 50 4c 52 00 01 78
123 0000050 10 07 9b 9d 40 02 00 10 10 0c 07 08 90 01 00 00
124 0000060 2c 00 00 00 24 00 00 00 20 db e6 ff ff ff ff ff
125 0000070 8d 00 00 00 00 00 00 00 08 37 e7 fd ff ff ff ff
126 0000080 ff 41 0e 10 86 02 43 0d 06 00 00 00 00 00 00 00
127 0000090 24 00 00 00 94 00 00 00 80 db e6 ff ff ff ff ff
128
129 $ hexdump fixtures/self/eh_frame | tail
130 0024040 06 50 83 07 8c 06 8d 05 8e 04 8f 03 00 00 00 00
131 0024050 24 00 00 00 7c 0e 00 00 30 a0 fb ff ff ff ff ff
132 0024060 15 00 00 00 00 00 00 00 00 41 0e 10 86 02 43 0d
133 0024070 06 00 00 00 00 00 00 00 24 00 00 00 a4 0e 00 00
134 0024080 28 a0 fb ff ff ff ff ff 1c 00 00 00 00 00 00 00
135 0024090 00 41 0e 10 86 02 43 0d 06 00 00 00 00 00 00 00
136 00240a0 24 00 00 00 cc 0e 00 00 20 a0 fb ff ff ff ff ff
137 00240b0 66 01 00 00 00 00 00 00 00 41 0e 10 86 02 43 0d
138 00240c0 06 00 00 00 00 00 00 00
139 ```
140
141 ## Linux
142
143 Something like this:
144
145 ```
146 objcopy --dump-section .eh_frame=fixtures/self/eh_frame path/to/binary
147 ```