forked from OSchip/llvm-project
[yaml2obj] - Add support of Offset for .strtab/.shstrtab/.dynstr sections.
These sections are implicit and handled a bit differently. Currently the "Offset" is ignored for them. This patch fixes an issue. Differential revision: https://reviews.llvm.org/D90446
This commit is contained in:
parent
71038788ce
commit
5ffafa870c
|
@ -930,7 +930,8 @@ void ELFState<ELFT>::initStrtabSectionHeader(Elf_Shdr &SHeader, StringRef Name,
|
|||
ELFYAML::RawContentSection *RawSec =
|
||||
dyn_cast_or_null<ELFYAML::RawContentSection>(YAMLSec);
|
||||
|
||||
SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign, /*Offset=*/None);
|
||||
SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign,
|
||||
YAMLSec ? YAMLSec->Offset : None);
|
||||
|
||||
if (RawSec && (RawSec->Content || RawSec->Size)) {
|
||||
SHeader.sh_size = writeContent(CBA, RawSec->Content, RawSec->Size);
|
||||
|
|
|
@ -23,25 +23,29 @@ Sections:
|
|||
- Name: .strtab
|
||||
Type: SHT_STRTAB
|
||||
Flags: [[STRTABFLAGS=<none>]]
|
||||
Offset: [[STRTABOFFSET=<none>]]
|
||||
- Name: .shstrtab
|
||||
Type: SHT_STRTAB
|
||||
Flags: [[SHSTRTABFLAGS=<none>]]
|
||||
Offset: [[SHSTRTABOFFSET=<none>]]
|
||||
- Name: .dynstr
|
||||
Type: SHT_STRTAB
|
||||
Flags: [[DYNSTRFLAGS=<none>]]
|
||||
Offset: [[DYNSTROFFSET=<none>]]
|
||||
|
||||
## Check we can set arbitrary flags for .strtab/.dynstr.
|
||||
## Check we can set arbitrary flags and offsets for
|
||||
## implicit string table sections.
|
||||
|
||||
# RUN: yaml2obj --docnum=1 \
|
||||
# RUN: -DSTRTABFLAGS="[ SHF_ALLOC, SHF_STRINGS ]" \
|
||||
# RUN: -DSHSTRTABFLAGS="[ SHF_ALLOC, SHF_WRITE ]" \
|
||||
# RUN: -DDYNSTRFLAGS="[ SHF_STRINGS ]" %s -o %t2
|
||||
# RUN: -DSTRTABFLAGS="[ SHF_ALLOC, SHF_STRINGS ]" -DSTRTABOFFSET=0x100 \
|
||||
# RUN: -DSHSTRTABFLAGS="[ SHF_ALLOC, SHF_WRITE ]" -DSHSTRTABOFFSET=0x200 \
|
||||
# RUN: -DDYNSTRFLAGS="[ SHF_STRINGS ]" -DDYNSTROFFSET=0x300 %s -o %t2
|
||||
# RUN: llvm-readelf %t2 --sections | FileCheck %s --check-prefix=CASE2
|
||||
|
||||
# CASE2: [Nr] Name Type {{.*}} Flg Lk
|
||||
# CASE2: [ 1] .strtab STRTAB {{.*}} AS 0
|
||||
# CASE2-NEXT: [ 2] .shstrtab STRTAB {{.*}} WA 0
|
||||
# CASE2-NEXT: [ 3] .dynstr STRTAB {{.*}} S 0
|
||||
# CASE2: [Nr] Name Type Address Off {{.*}} Flg Lk
|
||||
# CASE2: [ 1] .strtab STRTAB 0000000000000000 000100 {{.*}} AS 0
|
||||
# CASE2-NEXT: [ 2] .shstrtab STRTAB 0000000000000001 000200 {{.*}} WA 0
|
||||
# CASE2-NEXT: [ 3] .dynstr STRTAB 0000000000000000 000300 {{.*}} S 0
|
||||
|
||||
## Check no flags are set by default for implicit string table sections
|
||||
## when they are not described in the YAML.
|
||||
|
|
Loading…
Reference in New Issue