This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj][obj2yaml] - Stop using square brackets for unique suffixes.
ClosedPublic

Authored by grimar on May 18 2020, 7:29 AM.

Details

Summary

For describing section/symbol names we can use unique suffixes,
e.g:

- Name: '.foo [1]`
- Name: '.foo [2]`

It can be a problem (see https://reviews.llvm.org/D79984#inline-734829),
because [] are sometimes used to describe a macros:

- Name: "[[a0]]"

Seems the better approach is to use something else, like "()" or "<>".
This patch does it and refactors the code related.

Diff Detail

Event Timeline

grimar created this revision.May 18 2020, 7:29 AM
grimar planned changes to this revision.May 18 2020, 7:35 AM

I am going to change the new API to a better version.

grimar updated this revision to Diff 264621.May 18 2020, 7:49 AM
  • Refined new API.
grimar retitled this revision from [yaml2obj] - Stop using square brackets for unique suffixes. to [yaml2obj][obj2yaml] - Stop using square brackets for unique suffixes..May 18 2020, 8:11 AM
MaskRay accepted this revision.May 18 2020, 9:03 AM

LGTM.

This revision is now accepted and ready to land.May 18 2020, 9:03 AM

Just a couple of small test suggestions for documentation purposes.

llvm/test/tools/yaml2obj/ELF/duplicate-section-names.yaml
35–36

If I understand it correctly, '.foo2 (asbdjasbdjasbd)' is also a valid unique suffix. Perhaps worth showing that arbitrary contents are allowed in there?

llvm/test/tools/yaml2obj/ELF/duplicate-symbol-names.yaml
18

Same comment as above. Perhaps worth showing that the contents of the '()' can be arbitrary.

grimar marked 2 inline comments as done.May 19 2020, 1:40 AM
grimar added inline comments.
llvm/test/tools/yaml2obj/ELF/duplicate-section-names.yaml
35–36

We have such tests. See duplicate-symbol-and-section-names.yaml above:

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
  - Name: '.foo (555)'
    Type: SHT_PROGBITS
  - Name: '.foo (random_tag)'
    Type: SHT_PROGBITS
  - Name: .bar
    Type: SHT_PROGBITS
  - Name: '.bar (666)'
    Type: SHT_PROGBITS
  - Name: '.bar (random_tag)'
    Type: SHT_PROGBITS
Symbols:
  - Name: 'localfoo (111)'
  - Name: 'localfoo (222)'
  - Name: 'localfoo (random_tag)'
  - Name: 'localbar (333)'
  - Name: 'localbar (444)'
  - Name: 'localbar (random_tag)'
llvm/test/tools/yaml2obj/ELF/duplicate-symbol-names.yaml
18

The same.

jhenderson accepted this revision.May 19 2020, 2:28 AM

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.