Page MenuHomePhabricator

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

Authored by grimar on Mon, May 18, 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.Mon, May 18, 7:29 AM
Herald added a reviewer: alexshap. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
grimar planned changes to this revision.Mon, May 18, 7:35 AM

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

grimar updated this revision to Diff 264621.Mon, May 18, 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..Mon, May 18, 8:11 AM
MaskRay accepted this revision.Mon, May 18, 9:03 AM

LGTM.

This revision is now accepted and ready to land.Mon, May 18, 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.Tue, May 19, 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.Tue, May 19, 2:28 AM

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.