[PATCH] D71735: [ELF] Don't suggest an alternative spelling for a symbol in a discarded section
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 22 11:40:50 PST 2019
grimar added inline comments.
================
Comment at: lld/test/ELF/undef-not-suggest.s:1
+# REQUIRES: riscv
+## Check we don't suggest alternative spelling for relocations to symbols
----------------
MaskRay wrote:
> grimar wrote:
> > MaskRay wrote:
> > > grimar wrote:
> > > > I wonder if we should use yaml2obj (if possible) and make this test be not 'riscv' specific?
> > > A yaml2obj test will degrade test coverage.
> > >
> > > ```
> > > Symbols:
> > > - Name: foo
> > > Section: .text.foo
> > > - Name: for
> > > Section: .data
> > > - Name: .text.foo
> > > Type: STT_SECTION
> > > Section: .text.foo
> > > ### This symbol's name is ".data", instead of "" as produced by an assembler.
> > > ### We need a symbol with empty name for the `.quad .text.foo` test, to test that an empty name will not be suggested.
> > > - Name: .data
> > > Type: STT_SECTION
> > > Section: .data
> > > ```
> > I think there is no problem to use an empty name for a symbol.
> > Am I missing something? The following seems just works.
> >
> > ```
> > --- !ELF
> > FileHeader:
> > Class: ELFCLASS64
> > Data: ELFDATA2LSB
> > Type: ET_DYN
> > Machine: EM_RISCV
> > Sections:
> > - Name: .data
> > Type: SHT_PROGBITS
> > Symbols:
> > - Name: ""
> > Type: STT_SECTION
> > Section: .data
> > ```
> If we make the name of the STT_SECTION symbol `.text.foo` empty
>
> ```
> - Name: ""
> Type: STT_SECTION
> Section: .text.foo
> - Name: ""
> Type: STT_SECTION
> Section: .data
> ```
>
> Then we can't reference it in a relocation:
> ```
> - Name: .rela.rodata
> Type: SHT_RELA
> Link: .symtab
> Info: .rodata
> Relocations:
> - Offset: 0x0
> Symbol: .text.foo
> Type: R_X86_64_64
> - Offset: 0x8
> Symbol: foo
> Type: R_X86_64_64
> ```
>
> ```
> yaml2obj: error: unknown symbol referenced: '.text.foo' by YAML section '.rela.rodata'
> ```
But can't you reference it by index?
```
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .rodata
Type: SHT_PROGBITS
- Name: .text.foo
Type: SHT_PROGBITS
- Name: .rela.rodata
Type: SHT_RELA
Link: .symtab
Info: .rodata
Relocations:
- Offset: 0x0
Symbol: 1
Type: R_X86_64_64
Symbols:
- Name: ""
Type: STT_SECTION
Section: .text.foo
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71735/new/
https://reviews.llvm.org/D71735
More information about the llvm-commits
mailing list