-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This patch attempts to move as much code as possible out of the CreateSections function to make room for future improvements there. Some of this may be slightly over-engineered (VMAddressProvider), but I wanted to keep the logic of this function very simple, because once I start taking segment headers into acount (as discussed in D55356), the function is going to grow significantly. While in there, I also added tests for various bits of functionality. This should be NFC, except that I changed the order of hac^H^Heuristicks for determining section type slightly. Previously, name-based deduction (.symtab -> symtab) would take precedence over type-based (SHT_SYMTAB -> symtab) one. In fact we would assert if we ran into a .text section with type SHT_SYMTAB. Though unlikely to matter in practice, this order seemed wrong to me, so I have inverted it. Reviewers: clayborg, krytarowski, espindola Subscribers: emaste, arichardson, lldb-commits Differential Revision: https://reviews.llvm.org/D55706 llvm-svn: 349268
- Loading branch information
Showing
9 changed files
with
230 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# RUN: yaml2obj %s > %t | ||
# RUN: lldb-test object-file %t | FileCheck %s | ||
|
||
# CHECK-LABEL: Name: .one | ||
# CHECK: VM address: 0x0 | ||
|
||
# CHECK-LABEL: Name: .nonalloc | ||
# CHECK: VM address: 0x0 | ||
|
||
# CHECK-LABEL: Name: .two | ||
# CHECK: VM address: 0x8 | ||
|
||
# CHECK-LABEL: Name: .three | ||
# CHECK: VM address: 0xc | ||
|
||
# CHECK-LABEL: Name: .four | ||
# CHECK: VM address: 0xc | ||
|
||
# CHECK-LABEL: Name: .five | ||
# CHECK: VM address: 0x1000 | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Entry: 0x00000000000007A0 | ||
Sections: | ||
- Name: .one | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
AddressAlign: 0x0000000000000004 | ||
Content: DEADBEEFBAADF00D | ||
- Name: .nonalloc | ||
Type: SHT_PROGBITS | ||
AddressAlign: 0x0000000000000004 | ||
Content: DEADBEEFBAADF00D | ||
- Name: .two | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
AddressAlign: 0x0000000000000004 | ||
Content: DE | ||
- Name: .three | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
AddressAlign: 0x0000000000000004 | ||
- Name: .four | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
AddressAlign: 0x0000000000000004 | ||
Content: DEADBEEFBAADF00D | ||
- Name: .five | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
AddressAlign: 0x0000000000001000 | ||
Content: DEADBEEFBAADF00D | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# RUN: yaml2obj %s > %t | ||
# RUN: lldb-test object-file %t | FileCheck %s | ||
|
||
# CHECK-LABEL: Name: .r-x | ||
# CHECK: Permissions: r-x | ||
# | ||
# CHECK-LABEL: Name: .rw- | ||
# CHECK: Permissions: rw- | ||
|
||
# CHECK-LABEL: Name: .--- | ||
# CHECK: Permissions: --- | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_DYN | ||
Machine: EM_X86_64 | ||
Entry: 0x00000000000007A0 | ||
Sections: | ||
- Name: .r-x | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] | ||
Content: DEADBEEFBAADF00D | ||
- Name: .rw- | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
AddressAlign: 0x0000000000000004 | ||
Content: DEADBEEFBAADF00D | ||
- Name: .--- | ||
Type: SHT_PROGBITS | ||
AddressAlign: 0x0000000000000001 | ||
Content: DEADBEEFBAADF00D | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This test doesn't attempt to mandate a specific section classification. It is | ||
# here to document the existing behavior and to make sure we don't do something | ||
# completely crazy (like crashing). | ||
|
||
# RUN: yaml2obj %s > %t | ||
# RUN: lldb-test object-file %t | FileCheck %s | ||
|
||
# The section is called .data, but it has the SHF_EXECINSTR flag set. Have | ||
# the flag take precedence over the name. | ||
# CHECK-LABEL: Name: .data | ||
# CHECK-NEXT: Type: code | ||
|
||
# Section type (SHT_SYMTAB) takes precedence over name-based deduction. | ||
# CHECK-LABEL: Name: .text | ||
# CHECK-NEXT: Type: elf-symbol-table | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_DYN | ||
Machine: EM_X86_64 | ||
Entry: 0x00000000000007A0 | ||
Sections: | ||
- Name: .data | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_EXECINSTR, SHF_ALLOC ] | ||
AddressAlign: 0x0000000000000004 | ||
Content: DEADBEEFBAADF00D | ||
- Name: .text | ||
Type: SHT_SYMTAB | ||
Flags: [ ] | ||
AddressAlign: 0x0000000000000004 | ||
Content: DEADBEEFBAADF00D | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.