[llvm] r363367 - [yaml2obj] - Allow setting cutom Flags for implicit sections.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 07:23:56 PDT 2019


Should be fine now (r363401).
I'll watch for bots. 

Best regards,
George | Developer | Access Softek, Inc

________________________________________
От: George Rimar
Отправлено: 14 июня 2019 г. 17:09
Кому: Michael Kruse
Копия: llvm-commits
Тема: Re: [llvm] r363367 - [yaml2obj] - Allow setting cutom Flags for implicit sections.

Hi!

Sorry fo the issue. It was reverted in r363377 (not by me),
though that is not enough, because another commit depends on this.

I'll fix everything in a few minutes.

Best regards,
George | Developer | Access Softek, Inc

________________________________________
От: Michael Kruse <llvm-commits at meinersbur.de>
Отправлено: 14 июня 2019 г. 17:06
Кому: George Rimar
Копия: llvm-commits
Тема: Re: [llvm] r363367 - [yaml2obj] - Allow setting cutom Flags 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

Hi,

this might have caused buildbot failure:

http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/22/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Asymtab-implicit-sections-flags.yaml

Michael


Am Fr., 14. Juni 2019 um 05:57 Uhr schrieb George Rimar via
llvm-commits <llvm-commits at lists.llvm.org>:
>
> Author: grimar
> Date: Fri Jun 14 04:01:14 2019
> New Revision: 363367
>
> URL: http://llvm.org/viewvc/llvm-project?rev=363367&view=rev
> Log:
> [yaml2obj] - Allow setting cutom Flags for implicit sections.
>
> With this patch we get ability to set any flags we want
> for implicit sections defined in YAML.
>
> Differential revision: https://reviews.llvm.org/D63136
>
> Added:
>     llvm/trunk/test/tools/yaml2obj/strtab-implicit-sections-flags.yaml
>     llvm/trunk/test/tools/yaml2obj/symtab-implicit-sections-flags.yaml
> Modified:
>     llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
>     llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
>     llvm/trunk/tools/obj2yaml/elf2yaml.cpp
>     llvm/trunk/tools/yaml2obj/yaml2elf.cpp
>
> Modified: llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h?rev=363367&r1=363366&r2=363367&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h (original)
> +++ llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h Fri Jun 14 04:01:14 2019
> @@ -129,7 +129,7 @@ struct Section {
>    SectionKind Kind;
>    StringRef Name;
>    ELF_SHT Type;
> -  ELF_SHF Flags;
> +  Optional<ELF_SHF> Flags;
>    llvm::yaml::Hex64 Address;
>    StringRef Link;
>    llvm::yaml::Hex64 AddressAlign;
>
> Modified: llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/ELFYAML.cpp?rev=363367&r1=363366&r2=363367&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ObjectYAML/ELFYAML.cpp (original)
> +++ llvm/trunk/lib/ObjectYAML/ELFYAML.cpp Fri Jun 14 04:01:14 2019
> @@ -900,7 +900,7 @@ StringRef MappingTraits<ELFYAML::Symbol>
>  static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) {
>    IO.mapOptional("Name", Section.Name, StringRef());
>    IO.mapRequired("Type", Section.Type);
> -  IO.mapOptional("Flags", Section.Flags, ELFYAML::ELF_SHF(0));
> +  IO.mapOptional("Flags", Section.Flags);
>    IO.mapOptional("Address", Section.Address, Hex64(0));
>    IO.mapOptional("Link", Section.Link, StringRef());
>    IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
>
> Added: llvm/trunk/test/tools/yaml2obj/strtab-implicit-sections-flags.yaml
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/strtab-implicit-sections-flags.yaml?rev=363367&view=auto
> ==============================================================================
> --- llvm/trunk/test/tools/yaml2obj/strtab-implicit-sections-flags.yaml (added)
> +++ llvm/trunk/test/tools/yaml2obj/strtab-implicit-sections-flags.yaml Fri Jun 14 04:01:14 2019
> @@ -0,0 +1,79 @@
> +## For implicit string table sections, the `Flags` field can also
> +## be specified in YAML. Here we test the behavior in different cases.
> +
> +## When flags are not explicitly specified, yaml2obj assigns no flags
> +## for .strtab and the SHF_ALLOC flag for .dynstr by default.
> +
> +# RUN: yaml2obj --docnum=1 %s -o %t1
> +# RUN: llvm-readobj %t1 -S | FileCheck %s --check-prefix=CASE1
> +
> +# CASE1:      Name: .strtab
> +# CASE1-NEXT: Type: SHT_STRTAB
> +# CASE1-NEXT: Flags [
> +# CASE1-NEXT: ]
> +# CASE1:      Name: .dynstr
> +# CASE1-NEXT: Type: SHT_STRTAB
> +# CASE1-NEXT: Flags [
> +# CASE1-NEXT:   SHF_ALLOC
> +# CASE1-NEXT: ]
> +
> +--- !ELF
> +FileHeader:
> +  Class:   ELFCLASS64
> +  Data:    ELFDATA2LSB
> +  Type:    ET_DYN
> +  Machine: EM_X86_64
> +Sections:
> +  - Name:    .strtab
> +    Type:    SHT_STRTAB
> +  - Name:    .dynstr
> +    Type:    SHT_STRTAB
> +
> +## Check we can set arbitrary flags for .strtab/.dynstr.
> +
> +# RUN: yaml2obj --docnum=2 %s -o %t2
> +# RUN: llvm-readobj %t2 -S | FileCheck %s --check-prefix=CASE2
> +
> +# CASE2:      Name: .strtab
> +# CASE2-NEXT: Type: SHT_STRTAB
> +# CASE2-NEXT: Flags [
> +# CASE2-NEXT:   SHF_ALLOC
> +# CASE2-NEXT:   SHF_STRINGS
> +# CASE2-NEXT: ]
> +# CASE2:      Name: .dynstr
> +# CASE2-NEXT: Type: SHT_STRTAB
> +# CASE2-NEXT: Flags [
> +# CASE2-NEXT:   SHF_STRINGS
> +# CASE2-NEXT: ]
> +
> +--- !ELF
> +FileHeader:
> +  Class:   ELFCLASS64
> +  Data:    ELFDATA2LSB
> +  Type:    ET_DYN
> +  Machine: EM_X86_64
> +Sections:
> +  - Name:  .strtab
> +    Type:  SHT_STRTAB
> +    Flags: [ SHF_ALLOC, SHF_STRINGS ]
> +  - Name:  .dynstr
> +    Type:  SHT_STRTAB
> +    Flags: [ SHF_STRINGS ]
> +
> +## Check no flags are set by default for .strtab when it is not
> +## described in the YAML.
> +
> +# RUN: yaml2obj --docnum=3 %s -o %t3
> +# RUN: llvm-readobj %t3 -S | FileCheck %s --check-prefix=CASE3
> +
> +# CASE3:      Name: .strtab
> +# CASE3-NEXT: Type: SHT_STRTAB
> +# CASE3-NEXT: Flags [
> +# CASE3-NEXT: ]
> +
> +--- !ELF
> +FileHeader:
> +  Class:   ELFCLASS64
> +  Data:    ELFDATA2LSB
> +  Type:    ET_DYN
> +  Machine: EM_X86_64
>
> Added: llvm/trunk/test/tools/yaml2obj/symtab-implicit-sections-flags.yaml
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/symtab-implicit-sections-flags.yaml?rev=363367&view=auto
> ==============================================================================
> --- llvm/trunk/test/tools/yaml2obj/symtab-implicit-sections-flags.yaml (added)
> +++ llvm/trunk/test/tools/yaml2obj/symtab-implicit-sections-flags.yaml Fri Jun 14 04:01:14 2019
> @@ -0,0 +1,79 @@
> +## For implicit symbol table sections, the `Flags` field can also
> +## be specified in YAML. Here we test the behavior in different cases.
> +
> +## When flags are not explicitly specified, yaml2obj assigns no flags
> +## for .symtab and the SHF_ALLOC flag for .dynsym by default.
> +
> +# RUN: yaml2obj --docnum=1 %s -o %t1
> +# RUN: llvm-readobj %t1 -S | FileCheck %s --check-prefix=CASE1
> +
> +# CASE1:      Name: .symtab
> +# CASE1-NEXT: Type: SHT_SYMTAB
> +# CASE1-NEXT: Flags [
> +# CASE1-NEXT: ]
> +# CASE1:      Name: .dynsym
> +# CASE1-NEXT: Type: SHT_DYNSYM
> +# CASE1-NEXT: Flags [
> +# CASE1-NEXT:   SHF_ALLOC
> +# CASE1-NEXT: ]
> +
> +--- !ELF
> +FileHeader:
> +  Class:   ELFCLASS64
> +  Data:    ELFDATA2LSB
> +  Type:    ET_DYN
> +  Machine: EM_X86_64
> +Sections:
> +  - Name: .symtab
> +    Type: SHT_SYMTAB
> +  - Name: .dynsym
> +    Type: SHT_SYMTAB
> +
> +## Check we can set arbitrary flags for .symtab/.dynsym.
> +
> +# RUN: yaml2obj --docnum=2 %s -o %t2
> +# RUN: llvm-readobj %t2 -S | FileCheck %s --check-prefix=CASE2
> +
> +# CASE2:      Name: .symtab
> +# CASE2-NEXT: Type: SHT_SYMTAB
> +# CASE2-NEXT: Flags [
> +# CASE2-NEXT:   SHF_ALLOC
> +# CASE2-NEXT:   SHF_STRINGS
> +# CASE2-NEXT: ]
> +# CASE2:      Name: .dynsym
> +# CASE2-NEXT: Type: SHT_DYNSYM
> +# CASE2-NEXT: Flags [
> +# CASE2-NEXT:   SHF_STRINGS
> +# CASE2-NEXT: ]
> +
> +--- !ELF
> +FileHeader:
> +  Class:   ELFCLASS64
> +  Data:    ELFDATA2LSB
> +  Type:    ET_DYN
> +  Machine: EM_X86_64
> +Sections:
> +  - Name:  .symtab
> +    Type:  SHT_SYMTAB
> +    Flags: [ SHF_ALLOC, SHF_STRINGS ]
> +  - Name:  .dynsym
> +    Type:  SHT_SYMTAB
> +    Flags: [ SHF_STRINGS ]
> +
> +## Check no flags are set by default for .symtab when it is not
> +## described in the YAML.
> +
> +# RUN: yaml2obj --docnum=3 %s -o %t3
> +# RUN: llvm-readobj %t3 -S | FileCheck %s --check-prefix=CASE3
> +
> +# CASE3:      Name: .symtab
> +# CASE3-NEXT: Type: SHT_SYMTAB
> +# CASE3-NEXT: Flags [
> +# CASE3-NEXT: ]
> +
> +--- !ELF
> +FileHeader:
> +  Class:   ELFCLASS64
> +  Data:    ELFDATA2LSB
> +  Type:    ET_DYN
> +  Machine: EM_X86_64
>
> Modified: llvm/trunk/tools/obj2yaml/elf2yaml.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/elf2yaml.cpp?rev=363367&r1=363366&r2=363367&view=diff
> ==============================================================================
> --- llvm/trunk/tools/obj2yaml/elf2yaml.cpp (original)
> +++ llvm/trunk/tools/obj2yaml/elf2yaml.cpp Fri Jun 14 04:01:14 2019
> @@ -329,7 +329,8 @@ template <class ELFT>
>  std::error_code ELFDumper<ELFT>::dumpCommonSection(const Elf_Shdr *Shdr,
>                                                     ELFYAML::Section &S) {
>    S.Type = Shdr->sh_type;
> -  S.Flags = Shdr->sh_flags;
> +  if (Shdr->sh_flags)
> +    S.Flags = static_cast<ELFYAML::ELF_SHF>(Shdr->sh_flags);
>    S.Address = Shdr->sh_addr;
>    S.AddressAlign = Shdr->sh_addralign;
>    if (Shdr->sh_entsize)
>
> Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=363367&r1=363366&r2=363367&view=diff
> ==============================================================================
> --- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
> +++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Fri Jun 14 04:01:14 2019
> @@ -303,7 +303,8 @@ bool ELFState<ELFT>::initSectionHeaders(
>
>      SHeader.sh_name = DotShStrtab.getOffset(SecName);
>      SHeader.sh_type = Sec->Type;
> -    SHeader.sh_flags = Sec->Flags;
> +    if (Sec->Flags)
> +      SHeader.sh_flags = *Sec->Flags;
>      SHeader.sh_addr = Sec->Address;
>      SHeader.sh_addralign = Sec->AddressAlign;
>
> @@ -424,8 +425,10 @@ void ELFState<ELFT>::initSymtabSectionHe
>      SHeader.sh_link = Link;
>    }
>
> -  if (!IsStatic)
> -    SHeader.sh_flags |= ELF::SHF_ALLOC;
> +  if (YAMLSec && YAMLSec->Flags)
> +    SHeader.sh_flags = *YAMLSec->Flags;
> +  else if (!IsStatic)
> +    SHeader.sh_flags = ELF::SHF_ALLOC;
>
>    // If the symbol table section is explicitly described in the YAML
>    // then we should set the fields requested.
> @@ -481,14 +484,16 @@ void ELFState<ELFT>::initStrtabSectionHe
>    if (YAMLSec && YAMLSec->EntSize)
>      SHeader.sh_entsize = *YAMLSec->EntSize;
>
> +  if (YAMLSec && YAMLSec->Flags)
> +    SHeader.sh_flags = *YAMLSec->Flags;
> +  else if (Name == ".dynstr")
> +    SHeader.sh_flags = ELF::SHF_ALLOC;
> +
>    // If .dynstr section is explicitly described in the YAML
>    // then we want to use its section address.
> -  if (Name == ".dynstr") {
> -    if (YAMLSec)
> -      SHeader.sh_addr = YAMLSec->Address;
> -    // We assume that .dynstr is always allocatable.
> -    SHeader.sh_flags |= ELF::SHF_ALLOC;
> -  }
> +  // TODO: Allow this for any explicitly described section.
> +  if (YAMLSec && Name == ".dynstr")
> +    SHeader.sh_addr = YAMLSec->Address;
>  }
>
>  template <class ELFT>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list