[PATCH] D63596: [yaml2obj/obj2yaml] - Allow having the symbols and sections with duplicated names.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 05:04:07 PDT 2019


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added a subscriber: jakehehrlich.

Imagine we create an object from the following asm:

  .section .foo1,"ax",%progbits
  nop
  .section .foo,"ax",%progbits,unique,1
  nop
  .section .foo,"ax",%progbits,unique,2
  nop
  .section .foo2,"ax",%progbits
  nop

I.e. object has sections .foo1, .foo, .foo and .foo2.

obj2yaml has a broken logic and will produce YAML that has
the following sections: .foo1, .foo, .foo2, .foo23.

And there is no way to write a YAML that would allow yaml2obj
to produce the object with duplicated section names.

Now, lets take a look at a different case:

**file1.s:**

  .section .text.foo.1
  .local localfoo
  localfoo:
  nop
  
  .section .text.1,"ax",%progbits
  .quad localfoo

**file2.s:**

  .section .text.foo.2
  .local localfoo
  localfoo:
  nop
  
  .section .text.2,"ax",%progbits
  .quad localfoo

If we build the objects and link them with -r: `ld.bfd -r file1.o file2.o -o out`
then the resulting object will contain 2 symbols with the name `localfoo`.

obj2yaml can produce the YAML, but yaml2obj will fail to use it:
error: Repeated symbol name: 'localfoo'.

The solution I suggest in this patch is to use a special suffix
to encode the duplicated names of symbols and sections.
Test cases show the idea. The advantage is that the new style is simple and
code as almost not changed, though both describe issues are fixed.

BTW after I implemented it I had to fix the existent test and found that
my solution seems to be close (or maybe even the same) to one of the ideas mentioned by
Rafael in the rL312585 <https://reviews.llvm.org/rL312585> commit.


https://reviews.llvm.org/D63596

Files:
  test/Object/X86/obj2yaml-dup-section-name.s
  test/tools/obj2yaml/duplicate-symbol-names.test
  test/tools/yaml2obj/duplicate-section-names.test
  test/tools/yaml2obj/duplicate-symbol-names.test
  tools/obj2yaml/elf2yaml.cpp
  tools/yaml2obj/yaml2elf.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63596.205781.patch
Type: text/x-patch
Size: 11885 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190620/da43ba2b/attachment.bin>


More information about the llvm-commits mailing list