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:
.section .text.foo.1 .local localfoo localfoo: nop .section .text.1,"ax",%progbits .quad localfoo
.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 commit.