forked from OSchip/llvm-project
Fixed llvm-objcopy to add correct symbol table for ELF with program headers.
This fixes the following bugs: https://bugs.llvm.org/show_bug.cgi?id=43935 Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D102258
This commit is contained in:
parent
44642505ce
commit
d8e65585f7
llvm
|
@ -105,3 +105,26 @@ DynamicSymbols:
|
||||||
Binding: STB_GLOBAL
|
Binding: STB_GLOBAL
|
||||||
Symbols: []
|
Symbols: []
|
||||||
...
|
...
|
||||||
|
|
||||||
|
## Check the created .symtab is correct when there are program headers.
|
||||||
|
# RUN: yaml2obj --docnum=4 %s -o %t4
|
||||||
|
# RUN: llvm-objcopy %t4 %t4.add --add-symbol foo=1234
|
||||||
|
# RUN: llvm-readelf -s %t4.add | FileCheck --check-prefix=SEC4 %s
|
||||||
|
|
||||||
|
# SEC4: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
|
||||||
|
# SEC4-NEXT: 1: 00000000000004d2 0 NOTYPE GLOBAL DEFAULT ABS foo
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_DYN
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .foo
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
ProgramHeaders:
|
||||||
|
- Type: PT_LOAD
|
||||||
|
FirstSec: .foo
|
||||||
|
LastSec: .foo
|
||||||
|
...
|
||||||
|
|
|
@ -1205,6 +1205,10 @@ static bool sectionWithinSegment(const SectionBase &Sec, const Segment &Seg) {
|
||||||
// not the first.
|
// not the first.
|
||||||
uint64_t SecSize = Sec.Size ? Sec.Size : 1;
|
uint64_t SecSize = Sec.Size ? Sec.Size : 1;
|
||||||
|
|
||||||
|
// Ignore just added sections.
|
||||||
|
if (Sec.OriginalOffset == std::numeric_limits<uint64_t>::max())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (Sec.Type == SHT_NOBITS) {
|
if (Sec.Type == SHT_NOBITS) {
|
||||||
if (!(Sec.Flags & SHF_ALLOC))
|
if (!(Sec.Flags & SHF_ALLOC))
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue