[PATCH] D71735: [ELF] Don't suggest an alternative spelling for a symbol in a discarded section

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 21 09:28:06 PST 2019


MaskRay marked an inline comment as done.
MaskRay 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
----------------
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'
```


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