Files
clang-p2996/lldb/lit/Modules/ELF/section-overlap.yaml
Pavel Labath f55aea737f ELF: create "container" sections from PT_LOAD segments
Summary:
This is the result of the discussion in D55356, where it was suggested
as a solution to representing the addresses that logically belong to a
module in memory, but are not a part of any of its sections.

The ELF PT_LOAD segments are similar to the MachO "load commands",
except that the relationship between them and the object file sections
is a bit weaker. While in the MachO case, the sections belonging to a
specific segment are placed directly inside it in the object file
logical structur, in the ELF case, the sections and segments form two
separate hierarchies. This means that it is in theory possible to create
an elf file where only a part of a section would belong to some segment
(and another part to a different one). However, I am not aware of any
tool which would produce such a file (and most tools will have problems
ingesting them), so this means it is still possible to follow the MachO
model and make sections children of the PT_LOAD segments.

In case we run into (corrupt?) files with overlapping sections, I have
added code (and tests) which adjusts the sizes and/or drops the offending
sections in order to present a reasonable image to the upper layers of
LLDB. This is mostly done for completeness, as I don't anticipate
running into this situation in the real world. However, if we do run
into it, and the current behavior is not suitable for some reason, we
can implement this logic differently.

Reviewers: clayborg, jankratochvil, krytarowski, joerg, espindola

Subscribers: emaste, arichardson, lldb-commits

Differential Revision: https://reviews.llvm.org/D55998

llvm-svn: 350742
2019-01-09 16:50:45 +00:00

52 lines
1.4 KiB
YAML

# Test handling of (corrupt?) object files, which have sections with overlapping
# virtual addresses.
#
# Right now the overlapping sections get dropped, but other behaviors
# (including outright rejecting such files) are possible too.
# RUN: yaml2obj %s > %t
# RUN: lldb-test object-file %t | FileCheck %s
# CHECK-NOT: .overlap1
# CHECK-NOT: .overlap2
!ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_ARM
Sections:
- Name: .sect1
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1000
AddressAlign: 0x4
Content: DEADBEEFBAADF00D
- Name: .overlap1
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1004
AddressAlign: 0x4
Content: DEADBEEFBAADF00D
- Name: .sect2
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x2000
AddressAlign: 0x4
Content: DEADBEEFBAADF00D
- Name: .overlap2
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x2004
AddressAlign: 0x4
Content: DEADBEEFBAADF00D
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_W, PF_R ]
VAddr: 0x1000
Align: 0x4
Sections:
- Section: .sect1
- Section: .overlap1