[llvm] r363377 - [yaml2obj] - Allow setting custom section types for implicit sections.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 06:52:22 PDT 2019


Let me roll this back for now, so that we can commit other changes. Feel
free to resubmit once you figure out the issue and fix that.

On Fri, Jun 14, 2019 at 10:49 PM George Rimar <grimar at accesssoftek.com>
wrote:

> ​I'll take a look. Had no notification from BB :(
>
>
> Best regards,
> George | Developer | Access Softek, Inc
> ------------------------------
> *От:* Rui Ueyama <ruiu at google.com>
> *Отправлено:* 14 июня 2019 г. 16:47
> *Кому:* George Rimar
> *Копия:* llvm-commits
> *Тема:* Re: [llvm] r363377 - [yaml2obj] - Allow setting custom section
> types for implicit sections.
>
> CAUTION: This email originated from outside of the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.  If you suspect potential phishing or spam email,
> report it to ReportSpam at accesssoftek.com
> It looks like after this patch lld's test starts failing:
>
> FAIL: lld :: ELF/invalid/undefined-local-symbol-in-dso.test (889 of 2123)
> ******************** TEST 'lld ::
> ELF/invalid/undefined-local-symbol-in-dso.test' FAILED ********************
> Script:
> --
> : 'RUN: at line 11';   /home/ruiu/llvm/b/bin/yaml2obj
> /home/ruiu/llvm/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test -o
> /home/ruiu/llvm/b/tools/lld/test/ELF/invalid/Output/
> undefined-local-symbol-in-dso.test.tmp.so
> : 'RUN: at line 12';   /home/ruiu/llvm/b/bin/ld.lld
> /home/ruiu/llvm/b/tools/lld/test/ELF/invalid/Output/
> undefined-local-symbol-in-dso.test.tmp.so -o
> /home/ruiu/llvm/b/tools/lld/test/ELF/invalid/Output/undefined-local-symbol-in-dso.test.tmp
> 2>&1 | /home/ruiu/llvm/b/bin/FileCheck -check-prefix=WARN
> /home/ruiu/llvm/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /home/ruiu/llvm/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test:13:9:
> error: WARN: expected string not found in input
> # WARN: found local symbol 'foo' in global part of symbol table in file
> {{.*}}.so
>         ^
> <stdin>:1:1: note: scanning from here
> ld.lld: warning: cannot find entry symbol _start; not setting start address
> ^
> <stdin>:1:25: note: possible intended match here
> ld.lld: warning: cannot find entry symbol _start; not setting start address
>                         ^
>
> Can you take a look?
>
> On Fri, Jun 14, 2019 at 9:13 PM George Rimar via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: grimar
>> Date: Fri Jun 14 05:16:59 2019
>> New Revision: 363377
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=363377&view=rev
>> Log:
>> [yaml2obj] - Allow setting custom section types for implicit sections.
>>
>> We were hardcoding the final section type for sections that
>> are usually implicit. The patch fixes that.
>>
>> This also fixes a few issues in existent test cases and removes
>> one precompiled object.
>>
>> Differential revision: https://reviews.llvm.org/D63267
>>
>> Added:
>>     llvm/trunk/test/tools/yaml2obj/implicit-sections-types.test
>> Removed:
>>
>> llvm/trunk/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64
>> Modified:
>>     llvm/trunk/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
>>     llvm/trunk/test/tools/yaml2obj/elf-symtab-shinfo.yaml
>>     llvm/trunk/test/tools/yaml2obj/elf-symtab-shtype.yaml
>>     llvm/trunk/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml
>>     llvm/trunk/tools/yaml2obj/yaml2elf.cpp
>>
>> Removed:
>> llvm/trunk/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64?rev=363376&view=auto
>>
>> ==============================================================================
>> Binary file - no diff available.
>>
>> Modified: llvm/trunk/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test?rev=363377&r1=363376&r2=363377&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
>> (original)
>> +++ llvm/trunk/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test Fri
>> Jun 14 05:16:59 2019
>> @@ -1,11 +1,22 @@
>> -## wrong-shstrtab-type.elf-x86-64 contains .shstrtab section which has
>> SHT_PROGBITS type.
>> -## Check we do not fail to dump the section headers in this case.
>> +## Check we do not fail to dump the section headers when
>> +## a .shstrtab section does not have a SHT_STRTAB type.
>>
>> -# RUN: llvm-readobj -S %p/Inputs/wrong-shstrtab-type.elf-x86-64 |
>> FileCheck %s --check-prefix LLVM
>> -# RUN: llvm-readelf -S %p/Inputs/wrong-shstrtab-type.elf-x86-64 |
>> FileCheck %s --check-prefix GNU
>> +# RUN: yaml2obj %s -o %t1
>> +# RUN: llvm-readobj -S %t1 | FileCheck %s --check-prefix LLVM
>> +# RUN: llvm-readelf -S %t1 | FileCheck %s --check-prefix GNU
>>
>>  # LLVM:      Name: .shstrtab
>>  # LLVM-NEXT: Type: SHT_PROGBITS
>>
>>  # GNU: [Nr] Name      Type
>> -# GNU: [ 3] .shstrtab PROGBITS
>> +# GNU: [ 1] .shstrtab PROGBITS
>> +
>> +--- !ELF
>> +FileHeader:
>> +  Class:   ELFCLASS64
>> +  Data:    ELFDATA2LSB
>> +  Type:    ET_DYN
>> +  Machine: EM_X86_64
>> +Sections:
>> +  - Name: .shstrtab
>> +    Type: SHT_PROGBITS
>>
>> Modified: llvm/trunk/test/tools/yaml2obj/elf-symtab-shinfo.yaml
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/elf-symtab-shinfo.yaml?rev=363377&r1=363376&r2=363377&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/tools/yaml2obj/elf-symtab-shinfo.yaml (original)
>> +++ llvm/trunk/test/tools/yaml2obj/elf-symtab-shinfo.yaml Fri Jun 14
>> 05:16:59 2019
>> @@ -24,17 +24,17 @@
>>
>>  --- !ELF
>>  FileHeader:
>> -  Class:           ELFCLASS64
>> -  Data:            ELFDATA2LSB
>> -  Type:            ET_REL
>> -  Machine:         EM_X86_64
>> +  Class:   ELFCLASS64
>> +  Data:    ELFDATA2LSB
>> +  Type:    ET_REL
>> +  Machine: EM_X86_64
>>  Sections:
>> -  - Name:          .symtab
>> -    Info:          42
>> -    Type:          SHT_SYMTAB
>> -  - Name:          .dynsym
>> -    Info:          26
>> -    Type:          SHT_SYMTAB
>> +  - Name: .symtab
>> +    Info: 42
>> +    Type: SHT_SYMTAB
>> +  - Name: .dynsym
>> +    Info: 26
>> +    Type: SHT_DYNSYM
>>  Symbols:
>>    - Name:    foo
>>      Binding: STB_GLOBAL
>>
>> Modified: llvm/trunk/test/tools/yaml2obj/elf-symtab-shtype.yaml
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/elf-symtab-shtype.yaml?rev=363377&r1=363376&r2=363377&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/tools/yaml2obj/elf-symtab-shtype.yaml (original)
>> +++ llvm/trunk/test/tools/yaml2obj/elf-symtab-shtype.yaml Fri Jun 14
>> 05:16:59 2019
>> @@ -2,20 +2,18 @@
>>  # RUN: yaml2obj %s -o %t
>>  # RUN: llvm-readobj --sections %t | FileCheck %s
>>
>> -## TODO: the output is still SHT_SYMTAB because we do not yet
>> -## support changing it.
>>  # CHECK:      Name: .symtab
>> -# CHECK-NEXT: Type: SHT_SYMTAB
>> +# CHECK-NEXT: Type: SHT_DYNAMIC
>>
>>  --- !ELF
>> -FileHeader:
>> -  Class:           ELFCLASS64
>> -  Data:            ELFDATA2LSB
>> -  Type:            ET_REL
>> -  Machine:         EM_X86_64
>> -Sections:
>> -  - Name:            .symtab
>> -    Type:            SHT_DYNAMIC
>> +FileHeader:
>> +  Class:   ELFCLASS64
>> +  Data:    ELFDATA2LSB
>> +  Type:    ET_REL
>> +  Machine: EM_X86_64
>> +Sections:
>> +  - Name: .symtab
>> +    Type: SHT_DYNAMIC
>>  Symbols:
>>    - Name:    foo
>>      Binding: STB_GLOBAL
>>
>> Modified: llvm/trunk/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml?rev=363377&r1=363376&r2=363377&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml
>> (original)
>> +++ llvm/trunk/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml Fri Jun
>> 14 05:16:59 2019
>> @@ -19,4 +19,4 @@ FileHeader:
>>    Machine: EM_X86_64
>>  Sections:
>>    - Name: .dynsym
>> -    Type: SHT_SYMTAB
>> +    Type: SHT_DYNSYM
>>
>> Added: llvm/trunk/test/tools/yaml2obj/implicit-sections-types.test
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/implicit-sections-types.test?rev=363377&view=auto
>>
>> ==============================================================================
>> --- llvm/trunk/test/tools/yaml2obj/implicit-sections-types.test (added)
>> +++ llvm/trunk/test/tools/yaml2obj/implicit-sections-types.test Fri Jun
>> 14 05:16:59 2019
>> @@ -0,0 +1,69 @@
>> +## Here we check the types set for implicit sections
>> +## in different cases.
>> +
>> +## Check the types set by default in case sections were implicitly
>> +## added and not described in the YAML.
>> +
>> +# RUN: yaml2obj --docnum=1 %s -o %t1
>> +# RUN: llvm-readobj -S %t1 | FileCheck %s --check-prefix=CASE1
>> +
>> +# CASE1:      Name: .symtab
>> +# CASE1-NEXT: Type: SHT_SYMTAB
>> +# CASE1:      Name: .strtab
>> +# CASE1-NEXT: Type: SHT_STRTAB
>> +# CASE1:      Name: .shstrtab
>> +# CASE1-NEXT: Type: SHT_STRTAB
>> +# CASE1:      Name: .dynsym
>> +# CASE1-NEXT: Type: SHT_DYNSYM
>> +# CASE1:      Name: .dynstr
>> +# CASE1-NEXT: Type: SHT_STRTAB
>> +
>> +--- !ELF
>> +FileHeader:
>> +  Class:   ELFCLASS64
>> +  Data:    ELFDATA2LSB
>> +  Type:    ET_DYN
>> +  Machine: EM_X86_64
>> +## Needed to force the creation of the .dynsym and .dynstr.
>> +DynamicSymbols:
>> +  - Name:    foo
>> +  - Binding: STB_GLOBAL
>> +
>> +## Check we can set any arbitrary types when describing sections
>> +## that are usually implicit.
>> +
>> +# RUN: yaml2obj --docnum=2 %s -o %t2
>> +# RUN: llvm-readobj -S %t2 | FileCheck %s --check-prefix=CASE2
>> +
>> +# CASE2:      Name: .symtab
>> +# CASE2-NEXT: Type: SHT_DYNAMIC
>> +# CASE2:      Name: .strtab
>> +# CASE2-NEXT: Type: SHT_RELA
>> +# CASE2:      Name: .shstrtab
>> +# CASE2-NEXT: Type: SHT_PROGBITS
>> +# CASE2:      Name: .dynsym
>> +# CASE2-NEXT: Type: SHT_NOTE
>> +# CASE2:      Name: .dynstr
>> +# CASE2-NEXT: Type: SHT_NOBITS
>> +
>> +--- !ELF
>> +FileHeader:
>> +  Class:   ELFCLASS64
>> +  Data:    ELFDATA2LSB
>> +  Type:    ET_DYN
>> +  Machine: EM_X86_64
>> +Sections:
>> +  - Name: .symtab
>> +    Type: SHT_DYNAMIC
>> +  - Name: .strtab
>> +    Type: SHT_RELA
>> +  - Name: .shstrtab
>> +    Type: SHT_PROGBITS
>> +  - Name: .dynsym
>> +    Type: SHT_NOTE
>> +  - Name: .dynstr
>> +    Type: SHT_NOBITS
>> +## Needed to set the proper content size for .symtab, so
>> +## that llvm-readobj can dump this section.
>> +Symbols:
>> +  - Name: foo
>>
>> Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=363377&r1=363376&r2=363377&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
>> +++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Fri Jun 14 05:16:59 2019
>> @@ -403,7 +403,11 @@ void ELFState<ELFT>::initSymtabSectionHe
>>
>>    zero(SHeader);
>>    SHeader.sh_name = DotShStrtab.getOffset(IsStatic ? ".symtab" :
>> ".dynsym");
>> -  SHeader.sh_type = IsStatic ? ELF::SHT_SYMTAB : ELF::SHT_DYNSYM;
>> +
>> +  if (YAMLSec)
>> +    SHeader.sh_type = YAMLSec->Type;
>> +  else
>> +    SHeader.sh_type = IsStatic ? ELF::SHT_SYMTAB : ELF::SHT_DYNSYM;
>>
>>    if (RawSec && !RawSec->Link.empty()) {
>>      // If the Link field is explicitly defined in the document,
>> @@ -467,7 +471,7 @@ void ELFState<ELFT>::initStrtabSectionHe
>>                                               ELFYAML::Section *YAMLSec) {
>>    zero(SHeader);
>>    SHeader.sh_name = DotShStrtab.getOffset(Name);
>> -  SHeader.sh_type = ELF::SHT_STRTAB;
>> +  SHeader.sh_type = YAMLSec ? YAMLSec->Type : ELF::SHT_STRTAB;
>>    SHeader.sh_addralign = YAMLSec ? (uint64_t)YAMLSec->AddressAlign : 1;
>>
>>    ELFYAML::RawContentSection *RawSec =
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190614/0405fd80/attachment.html>


More information about the llvm-commits mailing list