Skip to content

Commit

Permalink
readobj/macho: fix section index (gimli-rs#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc authored Apr 30, 2024
1 parent 1851689 commit b6e2710
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion crates/examples/src/readobj/macho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ fn print_segment<S: Segment>(
}
if let Some(sections) = segment.sections(endian, section_data).print_err(p) {
for section in sections {
print_section(p, endian, data, section, state);
state.section_index += 1;
print_section(p, endian, data, section, state);
}
}
});
Expand Down
22 changes: 11 additions & 11 deletions crates/examples/testfiles/macho/base-aarch64-debug.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SegmentCommand {
NumberOfSections: 11
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x0
Expand Down Expand Up @@ -67,7 +67,7 @@ SegmentCommand {
}
}
Section {
Index: 1
Index: 2
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x34
Expand All @@ -79,7 +79,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 2
Index: 3
SectionName: "__debug_abbrev"
SegmentName: "__DWARF"
Address: 0x41
Expand All @@ -93,7 +93,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 3
Index: 4
SectionName: "__debug_info"
SegmentName: "__DWARF"
Address: 0x7B
Expand Down Expand Up @@ -123,7 +123,7 @@ SegmentCommand {
}
}
Section {
Index: 4
Index: 5
SectionName: "__debug_str"
SegmentName: "__DWARF"
Address: 0xCE
Expand All @@ -137,7 +137,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 5
Index: 6
SectionName: "__apple_names"
SegmentName: "__DWARF"
Address: 0x199
Expand All @@ -151,7 +151,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 6
Index: 7
SectionName: "__apple_objc"
SegmentName: "__DWARF"
Address: 0x1D5
Expand All @@ -165,7 +165,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 7
Index: 8
SectionName: "__apple_namespac"
SegmentName: "__DWARF"
Address: 0x1F9
Expand All @@ -179,7 +179,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 8
Index: 9
SectionName: "__apple_types"
SegmentName: "__DWARF"
Address: 0x21D
Expand All @@ -193,7 +193,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 9
Index: 10
SectionName: "__compact_unwind"
SegmentName: "__LD"
Address: 0x268
Expand All @@ -215,7 +215,7 @@ SegmentCommand {
}
}
Section {
Index: 10
Index: 11
SectionName: "__debug_line"
SegmentName: "__DWARF"
Address: 0x288
Expand Down
6 changes: 3 additions & 3 deletions crates/examples/testfiles/macho/base-aarch64.o.objcopy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SegmentCommand {
NumberOfSections: 3
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x0
Expand Down Expand Up @@ -67,7 +67,7 @@ SegmentCommand {
}
}
Section {
Index: 1
Index: 2
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x34
Expand All @@ -79,7 +79,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 2
Index: 3
SectionName: "__compact_unwind"
SegmentName: "__LD"
Address: 0x48
Expand Down
6 changes: 3 additions & 3 deletions crates/examples/testfiles/macho/base-aarch64.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SegmentCommand {
NumberOfSections: 3
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x0
Expand Down Expand Up @@ -67,7 +67,7 @@ SegmentCommand {
}
}
Section {
Index: 1
Index: 2
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x34
Expand All @@ -79,7 +79,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 2
Index: 3
SectionName: "__compact_unwind"
SegmentName: "__LD"
Address: 0x48
Expand Down
10 changes: 5 additions & 5 deletions crates/examples/testfiles/macho/base-aarch64.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SegmentCommand {
NumberOfSections: 4
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x100003F68
Expand All @@ -54,7 +54,7 @@ SegmentCommand {
S_ATTR_SOME_INSTRUCTIONS (0x400)
}
Section {
Index: 1
Index: 2
SectionName: "__stubs"
SegmentName: "__TEXT"
Address: 0x100003F9C
Expand All @@ -69,7 +69,7 @@ SegmentCommand {
S_ATTR_SOME_INSTRUCTIONS (0x400)
}
Section {
Index: 2
Index: 3
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x100003FA8
Expand All @@ -81,7 +81,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 3
Index: 4
SectionName: "__unwind_info"
SegmentName: "__TEXT"
Address: 0x100003FB8
Expand Down Expand Up @@ -111,7 +111,7 @@ SegmentCommand {
Flags: 0x10
SG_READ_ONLY (0x10)
Section {
Index: 4
Index: 5
SectionName: "__got"
SegmentName: "__DATA_CONST"
Address: 0x100004000
Expand Down
24 changes: 12 additions & 12 deletions crates/examples/testfiles/macho/base-x86_64-debug.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SegmentCommand {
NumberOfSections: 12
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x0
Expand Down Expand Up @@ -59,7 +59,7 @@ SegmentCommand {
}
}
Section {
Index: 1
Index: 2
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x25
Expand All @@ -71,7 +71,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 2
Index: 3
SectionName: "__debug_abbrev"
SegmentName: "__DWARF"
Address: 0x32
Expand All @@ -85,7 +85,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 3
Index: 4
SectionName: "__debug_info"
SegmentName: "__DWARF"
Address: 0x6C
Expand Down Expand Up @@ -115,7 +115,7 @@ SegmentCommand {
}
}
Section {
Index: 4
Index: 5
SectionName: "__debug_str"
SegmentName: "__DWARF"
Address: 0xBF
Expand All @@ -129,7 +129,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 5
Index: 6
SectionName: "__apple_names"
SegmentName: "__DWARF"
Address: 0x187
Expand All @@ -143,7 +143,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 6
Index: 7
SectionName: "__apple_objc"
SegmentName: "__DWARF"
Address: 0x1C3
Expand All @@ -157,7 +157,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 7
Index: 8
SectionName: "__apple_namespac"
SegmentName: "__DWARF"
Address: 0x1E7
Expand All @@ -171,7 +171,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 8
Index: 9
SectionName: "__apple_types"
SegmentName: "__DWARF"
Address: 0x20B
Expand All @@ -185,7 +185,7 @@ SegmentCommand {
S_ATTR_DEBUG (0x2000000)
}
Section {
Index: 9
Index: 10
SectionName: "__compact_unwind"
SegmentName: "__LD"
Address: 0x258
Expand All @@ -207,7 +207,7 @@ SegmentCommand {
}
}
Section {
Index: 10
Index: 11
SectionName: "__eh_frame"
SegmentName: "__TEXT"
Address: 0x278
Expand All @@ -223,7 +223,7 @@ SegmentCommand {
S_ATTR_LIVE_SUPPORT (0x8000000)
}
Section {
Index: 11
Index: 12
SectionName: "__debug_line"
SegmentName: "__DWARF"
Address: 0x2B8
Expand Down
8 changes: 4 additions & 4 deletions crates/examples/testfiles/macho/base-x86_64.o.objcopy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SegmentCommand {
NumberOfSections: 4
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x0
Expand Down Expand Up @@ -59,7 +59,7 @@ SegmentCommand {
}
}
Section {
Index: 1
Index: 2
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x25
Expand All @@ -71,7 +71,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 2
Index: 3
SectionName: "__compact_unwind"
SegmentName: "__LD"
Address: 0x38
Expand All @@ -93,7 +93,7 @@ SegmentCommand {
}
}
Section {
Index: 3
Index: 4
SectionName: "__eh_frame"
SegmentName: "__TEXT"
Address: 0x58
Expand Down
8 changes: 4 additions & 4 deletions crates/examples/testfiles/macho/base-x86_64.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SegmentCommand {
NumberOfSections: 4
Flags: 0x0
Section {
Index: 0
Index: 1
SectionName: "__text"
SegmentName: "__TEXT"
Address: 0x0
Expand Down Expand Up @@ -59,7 +59,7 @@ SegmentCommand {
}
}
Section {
Index: 1
Index: 2
SectionName: "__cstring"
SegmentName: "__TEXT"
Address: 0x25
Expand All @@ -71,7 +71,7 @@ SegmentCommand {
Flags: S_CSTRING_LITERALS (0x2)
}
Section {
Index: 2
Index: 3
SectionName: "__compact_unwind"
SegmentName: "__LD"
Address: 0x38
Expand All @@ -93,7 +93,7 @@ SegmentCommand {
}
}
Section {
Index: 3
Index: 4
SectionName: "__eh_frame"
SegmentName: "__TEXT"
Address: 0x58
Expand Down
Loading

0 comments on commit b6e2710

Please sign in to comment.