Skip to content

Commit cf8a50c

Browse files
committed
decode: Use stable sort for values to not change order or values with same range start
Some decoders might relay on values added with same start to be kept in same order.
1 parent 2173d9e commit cf8a50c

File tree

9 files changed

+199
-198
lines changed

9 files changed

+199
-198
lines changed

format/elf/testdata/linux_386/libbbb.a.fqtest

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,36 +141,7 @@ $ fq -d ar v libbbb.a
141141
0x3d0| 01 00| ..| addralign: 1 0x3de-0x3e1.7 (4)
142142
0x3e0|00 00 |.. |
143143
0x3e0| 00 00 00 00 | .... | entsize: 0 0x3e2-0x3e5.7 (4)
144-
| | | [3]{}: section_header 0x115-0x485.7 (881)
145-
0x110| 6c 69 62 62 62 62 5f 62 62 62 00| libbbb_bbb.| data: raw bits 0x115-0x11f.7 (11)
146-
0x450| 30 00| 0.| name: ".rodata" (48) 0x45e-0x461.7 (4)
147-
0x460|00 00 |.. |
148-
0x460| 01 00 00 00 | .... | type: "progbits" (0x1) (Information defined by the program) 0x462-0x465.7 (4)
149-
| | | flags{}: 0x466-0x469.7 (4)
150-
0x460| 02 | . | link_order: false 0x466-0x466 (0.1)
151-
0x460| 02 | . | info_link: false 0x466.1-0x466.1 (0.1)
152-
0x460| 02 | . | strings: false 0x466.2-0x466.2 (0.1)
153-
0x460| 02 | . | merge: false 0x466.3-0x466.3 (0.1)
154-
0x460| 02 | . | unused0: 0 0x466.4-0x466.4 (0.1)
155-
0x460| 02 | . | execinstr: false 0x466.5-0x466.5 (0.1)
156-
0x460| 02 | . | alloc: true 0x466.6-0x466.6 (0.1)
157-
0x460| 02 | . | write: false 0x466.7-0x466.7 (0.1)
158-
0x460| 00 | . | tls: false 0x467-0x467 (0.1)
159-
0x460| 00 | . | group: false 0x467.1-0x467.1 (0.1)
160-
0x460| 00 | . | os_nonconforming: false 0x467.2-0x467.2 (0.1)
161-
0x460| 00 00 | .. | unused1: 0 0x467.3-0x468.3 (1.1)
162-
0x460| 00 00 | .. | os_specific: 0 0x468.4-0x469.3 (1)
163-
0x460| 00 | . | processor_specific: 0 0x469.4-0x469.7 (0.4)
164-
0x460| 00 00 00 00 | .... | addr: 0x0 0x46a-0x46d.7 (4)
165-
0x460| 67 00| g.| offset: 103 0x46e-0x471.7 (4)
166-
0x470|00 00 |.. |
167-
0x470| 0b 00 00 00 | .... | size: 0xb 0x472-0x475.7 (4)
168-
0x470| 00 00 00 00 | .... | link: 0 0x476-0x479.7 (4)
169-
0x470| 00 00 00 00 | .... | info: 0 0x47a-0x47d.7 (4)
170-
0x470| 01 00| ..| addralign: 1 0x47e-0x481.7 (4)
171-
0x480|00 00 |.. |
172-
0x480| 00 00 00 00 | .... | entsize: 0 0x482-0x485.7 (4)
173-
| | | [4]{}: section_header 0x115-0x435.7 (801)
144+
| | | [3]{}: section_header 0x115-0x435.7 (801)
174145
| | | data: raw bits 0x115-NA (0)
175146
0x400| 25 00| %.| name: ".data" (37) 0x40e-0x411.7 (4)
176147
0x410|00 00 |.. |
@@ -199,6 +170,35 @@ $ fq -d ar v libbbb.a
199170
0x420| 01 00| ..| addralign: 1 0x42e-0x431.7 (4)
200171
0x430|00 00 |.. |
201172
0x430| 00 00 00 00 | .... | entsize: 0 0x432-0x435.7 (4)
173+
| | | [4]{}: section_header 0x115-0x485.7 (881)
174+
0x110| 6c 69 62 62 62 62 5f 62 62 62 00| libbbb_bbb.| data: raw bits 0x115-0x11f.7 (11)
175+
0x450| 30 00| 0.| name: ".rodata" (48) 0x45e-0x461.7 (4)
176+
0x460|00 00 |.. |
177+
0x460| 01 00 00 00 | .... | type: "progbits" (0x1) (Information defined by the program) 0x462-0x465.7 (4)
178+
| | | flags{}: 0x466-0x469.7 (4)
179+
0x460| 02 | . | link_order: false 0x466-0x466 (0.1)
180+
0x460| 02 | . | info_link: false 0x466.1-0x466.1 (0.1)
181+
0x460| 02 | . | strings: false 0x466.2-0x466.2 (0.1)
182+
0x460| 02 | . | merge: false 0x466.3-0x466.3 (0.1)
183+
0x460| 02 | . | unused0: 0 0x466.4-0x466.4 (0.1)
184+
0x460| 02 | . | execinstr: false 0x466.5-0x466.5 (0.1)
185+
0x460| 02 | . | alloc: true 0x466.6-0x466.6 (0.1)
186+
0x460| 02 | . | write: false 0x466.7-0x466.7 (0.1)
187+
0x460| 00 | . | tls: false 0x467-0x467 (0.1)
188+
0x460| 00 | . | group: false 0x467.1-0x467.1 (0.1)
189+
0x460| 00 | . | os_nonconforming: false 0x467.2-0x467.2 (0.1)
190+
0x460| 00 00 | .. | unused1: 0 0x467.3-0x468.3 (1.1)
191+
0x460| 00 00 | .. | os_specific: 0 0x468.4-0x469.3 (1)
192+
0x460| 00 | . | processor_specific: 0 0x469.4-0x469.7 (0.4)
193+
0x460| 00 00 00 00 | .... | addr: 0x0 0x46a-0x46d.7 (4)
194+
0x460| 67 00| g.| offset: 103 0x46e-0x471.7 (4)
195+
0x470|00 00 |.. |
196+
0x470| 0b 00 00 00 | .... | size: 0xb 0x472-0x475.7 (4)
197+
0x470| 00 00 00 00 | .... | link: 0 0x476-0x479.7 (4)
198+
0x470| 00 00 00 00 | .... | info: 0 0x47a-0x47d.7 (4)
199+
0x470| 01 00| ..| addralign: 1 0x47e-0x481.7 (4)
200+
0x480|00 00 |.. |
201+
0x480| 00 00 00 00 | .... | entsize: 0 0x482-0x485.7 (4)
202202
| | | [5]{}: section_header 0x120-0x4ad.7 (910)
203203
0x120|8b 04 24 c3 |..$. | data: raw bits 0x120-0x123.7 (4)
204204
0x480| 38 00 00 00 | 8... | name: ".text.__x86.get_pc_thunk.ax" (56) 0x486-0x489.7 (4)

format/elf/testdata/linux_amd64/libbbb.a.fqtest

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,37 @@ $ fq -d ar v libbbb.a
207207
0x4a0| 01 00 00 00| ....| addralign: 1 0x4ac-0x4b3.7 (8)
208208
0x4b0|00 00 00 00 |.... |
209209
0x4b0| 01 00 00 00 00 00 00 00 | ........ | entsize: 1 0x4b4-0x4bb.7 (8)
210-
| | | [5]{}: section_header 0x124-0x53b.7 (1048)
210+
| | | [5]{}: section_header 0x124-0x4fb.7 (984)
211+
| | | data: raw bits 0x124-NA (0)
212+
0x4b0| 42 00 00 00| B...| name: ".note.GNU-stack" (66) 0x4bc-0x4bf.7 (4)
213+
0x4c0|01 00 00 00 |.... | type: "progbits" (0x1) (Information defined by the program) 0x4c0-0x4c3.7 (4)
214+
| | | flags{}: 0x4c4-0x4cb.7 (8)
215+
0x4c0| 00 | . | link_order: false 0x4c4-0x4c4 (0.1)
216+
0x4c0| 00 | . | info_link: false 0x4c4.1-0x4c4.1 (0.1)
217+
0x4c0| 00 | . | strings: false 0x4c4.2-0x4c4.2 (0.1)
218+
0x4c0| 00 | . | merge: false 0x4c4.3-0x4c4.3 (0.1)
219+
0x4c0| 00 | . | unused0: 0 0x4c4.4-0x4c4.4 (0.1)
220+
0x4c0| 00 | . | execinstr: false 0x4c4.5-0x4c4.5 (0.1)
221+
0x4c0| 00 | . | alloc: false 0x4c4.6-0x4c4.6 (0.1)
222+
0x4c0| 00 | . | write: false 0x4c4.7-0x4c4.7 (0.1)
223+
0x4c0| 00 | . | tls: false 0x4c5-0x4c5 (0.1)
224+
0x4c0| 00 | . | group: false 0x4c5.1-0x4c5.1 (0.1)
225+
0x4c0| 00 | . | os_nonconforming: false 0x4c5.2-0x4c5.2 (0.1)
226+
0x4c0| 00 00 | .. | unused1: 0 0x4c5.3-0x4c6.3 (1.1)
227+
0x4c0| 00 00 | .. | os_specific: 0 0x4c6.4-0x4c7.3 (1)
228+
0x4c0| 00 | . | processor_specific: 0 0x4c7.4-0x4c7.7 (0.4)
229+
0x4c0| 00 00 00 00 | .... | unused2: 0 0x4c8-0x4cb.7 (4)
230+
0x4c0| 00 00 00 00| ....| addr: 0x0 0x4cc-0x4d3.7 (8)
231+
0x4d0|00 00 00 00 |.... |
232+
0x4d0| 90 00 00 00 00 00 00 00 | ........ | offset: 0x90 0x4d4-0x4db.7 (8)
233+
0x4d0| 00 00 00 00| ....| size: 0 0x4dc-0x4e3.7 (8)
234+
0x4e0|00 00 00 00 |.... |
235+
0x4e0| 00 00 00 00 | .... | link: 0 0x4e4-0x4e7.7 (4)
236+
0x4e0| 00 00 00 00 | .... | info: 0 0x4e8-0x4eb.7 (4)
237+
0x4e0| 01 00 00 00| ....| addralign: 1 0x4ec-0x4f3.7 (8)
238+
0x4f0|00 00 00 00 |.... |
239+
0x4f0| 00 00 00 00 00 00 00 00 | ........ | entsize: 0 0x4f4-0x4fb.7 (8)
240+
| | | [6]{}: section_header 0x124-0x53b.7 (1048)
211241
0x120| 04 00 00 00 20 00 00 00 05 00 00 00| .... .......| data: raw bits 0x124-0x153.7 (48)
212242
0x130|47 4e 55 00 02 00 01 c0 04 00 00 00 00 00 00 00|GNU.............|
213243
* |until 0x153.7 (48) | |
@@ -239,36 +269,6 @@ $ fq -d ar v libbbb.a
239269
0x520| 08 00 00 00| ....| addralign: 8 0x52c-0x533.7 (8)
240270
0x530|00 00 00 00 |.... |
241271
0x530| 00 00 00 00 00 00 00 00 | ........ | entsize: 0 0x534-0x53b.7 (8)
242-
| | | [6]{}: section_header 0x124-0x4fb.7 (984)
243-
| | | data: raw bits 0x124-NA (0)
244-
0x4b0| 42 00 00 00| B...| name: ".note.GNU-stack" (66) 0x4bc-0x4bf.7 (4)
245-
0x4c0|01 00 00 00 |.... | type: "progbits" (0x1) (Information defined by the program) 0x4c0-0x4c3.7 (4)
246-
| | | flags{}: 0x4c4-0x4cb.7 (8)
247-
0x4c0| 00 | . | link_order: false 0x4c4-0x4c4 (0.1)
248-
0x4c0| 00 | . | info_link: false 0x4c4.1-0x4c4.1 (0.1)
249-
0x4c0| 00 | . | strings: false 0x4c4.2-0x4c4.2 (0.1)
250-
0x4c0| 00 | . | merge: false 0x4c4.3-0x4c4.3 (0.1)
251-
0x4c0| 00 | . | unused0: 0 0x4c4.4-0x4c4.4 (0.1)
252-
0x4c0| 00 | . | execinstr: false 0x4c4.5-0x4c4.5 (0.1)
253-
0x4c0| 00 | . | alloc: false 0x4c4.6-0x4c4.6 (0.1)
254-
0x4c0| 00 | . | write: false 0x4c4.7-0x4c4.7 (0.1)
255-
0x4c0| 00 | . | tls: false 0x4c5-0x4c5 (0.1)
256-
0x4c0| 00 | . | group: false 0x4c5.1-0x4c5.1 (0.1)
257-
0x4c0| 00 | . | os_nonconforming: false 0x4c5.2-0x4c5.2 (0.1)
258-
0x4c0| 00 00 | .. | unused1: 0 0x4c5.3-0x4c6.3 (1.1)
259-
0x4c0| 00 00 | .. | os_specific: 0 0x4c6.4-0x4c7.3 (1)
260-
0x4c0| 00 | . | processor_specific: 0 0x4c7.4-0x4c7.7 (0.4)
261-
0x4c0| 00 00 00 00 | .... | unused2: 0 0x4c8-0x4cb.7 (4)
262-
0x4c0| 00 00 00 00| ....| addr: 0x0 0x4cc-0x4d3.7 (8)
263-
0x4d0|00 00 00 00 |.... |
264-
0x4d0| 90 00 00 00 00 00 00 00 | ........ | offset: 0x90 0x4d4-0x4db.7 (8)
265-
0x4d0| 00 00 00 00| ....| size: 0 0x4dc-0x4e3.7 (8)
266-
0x4e0|00 00 00 00 |.... |
267-
0x4e0| 00 00 00 00 | .... | link: 0 0x4e4-0x4e7.7 (4)
268-
0x4e0| 00 00 00 00 | .... | info: 0 0x4e8-0x4eb.7 (4)
269-
0x4e0| 01 00 00 00| ....| addralign: 1 0x4ec-0x4f3.7 (8)
270-
0x4f0|00 00 00 00 |.... |
271-
0x4f0| 00 00 00 00 00 00 00 00 | ........ | entsize: 0 0x4f4-0x4fb.7 (8)
272272
| | | [7]{}: section_header 0x154-0x57b.7 (1064)
273273
0x150| 14 00 00 00 00 00 00 00 01 7a 52 00| .........zR.| data: raw bits 0x154-0x18b.7 (56)
274274
0x160|01 78 10 01 1b 0c 07 08 90 01 00 00 1c 00 00 00|.x..............|

0 commit comments

Comments
 (0)