[lld] Linker cannot handle sections with non-unique names

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[lld] Linker cannot handle sections with non-unique names

Simon Atanasyan-2
Hi,

FYI

LLD cannot handle ELF sections with non-unique names. An object file
with such sections can be generated by the Clang since r234143. I am
not sure that Clang works absolutely correct but bfd linker works
fine.

Right now I do not have a time to investigate this problem. If nobody
take, I will try to solve it later.

Here is the reproduction script for x86_64 host:

$ cat test.cc
template <class T>
void foo(T) {}

int main() {
  foo(0);
  foo(1.0);
}

$ clang++ -c test.cc -fno-unique-section-names
$ lld -flavor gnu -target x86_64 --hash-style=both --build-id \
  --eh-frame-hdr -m elf_x86_64 \
  -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out \
  <bunch of regular linker arguments here>
$ ./a.out
Illegal instruction

$ clang++ -c test.cc -funique-section-names
$ lld -flavor gnu -target x86_64 --hash-style=both --build-id \
  --eh-frame-hdr -m elf_x86_64 \
  -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out \
  <bunch of regular linker arguments here>
$ ./a.out

--
Simon Atanasyan
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

shankarke
Thanks Simon fir the test. I may be able to get  to this issue later too. The bug is mostly in the elf reader where it's skipping real sections with the same name.



> On Apr 18, 2015, at 06:52, Simon Atanasyan <[hidden email]> wrote:
>
> Hi,
>
> FYI
>
> LLD cannot handle ELF sections with non-unique names. An object file
> with such sections can be generated by the Clang since r234143. I am
> not sure that Clang works absolutely correct but bfd linker works
> fine.
>
> Right now I do not have a time to investigate this problem. If nobody
> take, I will try to solve it later.
>
> Here is the reproduction script for x86_64 host:
>
> $ cat test.cc
> template <class T>
> void foo(T) {}
>
> int main() {
>  foo(0);
>  foo(1.0);
> }
>
> $ clang++ -c test.cc -fno-unique-section-names
> $ lld -flavor gnu -target x86_64 --hash-style=both --build-id \
>  --eh-frame-hdr -m elf_x86_64 \
>  -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out \
>  <bunch of regular linker arguments here>
> $ ./a.out
> Illegal instruction
>
> $ clang++ -c test.cc -funique-section-names
> $ lld -flavor gnu -target x86_64 --hash-style=both --build-id \
>  --eh-frame-hdr -m elf_x86_64 \
>  -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out \
>  <bunch of regular linker arguments here>
> $ ./a.out
>
> --
> Simon Atanasyan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

shankarke
In reply to this post by Simon Atanasyan-2
Attached patch fixes the issue.

On Sat, Apr 18, 2015 at 6:52 AM, Simon Atanasyan <[hidden email]> wrote:
Hi,

FYI

LLD cannot handle ELF sections with non-unique names. An object file
with such sections can be generated by the Clang since r234143. I am
not sure that Clang works absolutely correct but bfd linker works
fine.

Right now I do not have a time to investigate this problem. If nobody
take, I will try to solve it later.

Here is the reproduction script for x86_64 host:

$ cat test.cc
template <class T>
void foo(T) {}

int main() {
  foo(0);
  foo(1.0);
}

$ clang++ -c test.cc -fno-unique-section-names
$ lld -flavor gnu -target x86_64 --hash-style=both --build-id \
  --eh-frame-hdr -m elf_x86_64 \
  -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out \
  <bunch of regular linker arguments here>
$ ./a.out
Illegal instruction

$ clang++ -c test.cc -funique-section-names
$ lld -flavor gnu -target x86_64 --hash-style=both --build-id \
  --eh-frame-hdr -m elf_x86_64 \
  -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out \
  <bunch of regular linker arguments here>
$ ./a.out

--
Simon Atanasyan


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

no-unique-sections.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

Davide Italiano
On Sun, Apr 19, 2015 at 3:44 PM, Shankar Easwaran <[hidden email]> wrote:
> Attached patch fixes the issue.
>

This seems OK to me but please add a testcase.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

Simon Atanasyan-2
In reply to this post by shankarke
On Mon, Apr 20, 2015 at 1:44 AM, Shankar Easwaran <[hidden email]> wrote:
> Attached patch fixes the issue.

Thanks for the quick fix. The patch LGTM if you add a test case.
Unfortunately yaml2obj does not support duplicated section names but
we can use a binary input file.

--
Simon Atanasyan
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

shankarke
I plan to add a test case but couldn't add because of yaml2obj support. I am adding that support to yaml2obj and obj2yaml and push this patch later. I don't like the idea of adding binary files to the test repo as we need to keep cleaning up later.



> On Apr 20, 2015, at 03:34, Simon Atanasyan <[hidden email]> wrote:
>
>> On Mon, Apr 20, 2015 at 1:44 AM, Shankar Easwaran <[hidden email]> wrote:
>> Attached patch fixes the issue.
>
> Thanks for the quick fix. The patch LGTM if you add a test case.
> Unfortunately yaml2obj does not support duplicated section names but
> we can use a binary input file.
>
> --
> Simon Atanasyan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

Rafael Espíndola
On 20 April 2015 at 10:59, Shankar Easwaram <[hidden email]> wrote:
> I plan to add a test case but couldn't add because of yaml2obj support. I am adding that support to yaml2obj and obj2yaml and push this patch later. I don't like the idea of adding binary files to the test repo as we need to keep cleaning up later.

IMHO checking in a binary would actually be better.

Binaries are the input to the linker. What is desired in here is to
test that lld can work with a binary produced by a current clang. That
should still be the case in 1 year, even if what clang is producing is
different. Using yaml2obj just makes that connection more tenuous.

Cheers,
Rafael
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

Sean Silva-2
In reply to this post by shankarke


On Mon, Apr 20, 2015 at 7:59 AM, Shankar Easwaram <[hidden email]> wrote:
I plan to add a test case but couldn't add because of yaml2obj support. I am adding that support to yaml2obj and obj2yaml and push this patch later. I don't like the idea of adding binary files to the test repo as we need to keep cleaning up later.

Please make sure to pre-commit review this. I expect a bikeshed over the syntax.

-- Sean Silva
 



> On Apr 20, 2015, at 03:34, Simon Atanasyan <[hidden email]> wrote:
>
>> On Mon, Apr 20, 2015 at 1:44 AM, Shankar Easwaran <[hidden email]> wrote:
>> Attached patch fixes the issue.
>
> Thanks for the quick fix. The patch LGTM if you add a test case.
> Unfortunately yaml2obj does not support duplicated section names but
> we can use a binary input file.
>
> --
> Simon Atanasyan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

Rui Ueyama
In reply to this post by shankarke
Nothing wrong with going ahead with a temporary measure if the temporary measure is reasonable (besides the discussion if checking in binary files is desirable). Even if you plan to add a test written in YAML, it's better to check in a binary at least for now than checking it in without any tests.

On Mon, Apr 20, 2015 at 7:59 AM, Shankar Easwaram <[hidden email]> wrote:
I plan to add a test case but couldn't add because of yaml2obj support. I am adding that support to yaml2obj and obj2yaml and push this patch later. I don't like the idea of adding binary files to the test repo as we need to keep cleaning up later.



> On Apr 20, 2015, at 03:34, Simon Atanasyan <[hidden email]> wrote:
>
>> On Mon, Apr 20, 2015 at 1:44 AM, Shankar Easwaran <[hidden email]> wrote:
>> Attached patch fixes the issue.
>
> Thanks for the quick fix. The patch LGTM if you add a test case.
> Unfortunately yaml2obj does not support duplicated section names but
> we can use a binary input file.
>
> --
> Simon Atanasyan


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

Simon Atanasyan-2
I have committed the patch with added test case at r238115.
It is better to do not keep a window broken for so long time.

On Mon, Apr 20, 2015 at 11:49 PM, Rui Ueyama <[hidden email]> wrote:

> Nothing wrong with going ahead with a temporary measure if the temporary
> measure is reasonable (besides the discussion if checking in binary files is
> desirable). Even if you plan to add a test written in YAML, it's better to
> check in a binary at least for now than checking it in without any tests.
>
> On Mon, Apr 20, 2015 at 7:59 AM, Shankar Easwaram <[hidden email]>
> wrote:
>>
>> I plan to add a test case but couldn't add because of yaml2obj support. I
>> am adding that support to yaml2obj and obj2yaml and push this patch later. I
>> don't like the idea of adding binary files to the test repo as we need to
>> keep cleaning up later.
>>
>>
>>
>> > On Apr 20, 2015, at 03:34, Simon Atanasyan <[hidden email]> wrote:
>> >
>> >> On Mon, Apr 20, 2015 at 1:44 AM, Shankar Easwaran <[hidden email]>
>> >> wrote:
>> >> Attached patch fixes the issue.
>> >
>> > Thanks for the quick fix. The patch LGTM if you add a test case.
>> > Unfortunately yaml2obj does not support duplicated section names but
>> > we can use a binary input file.

--
Simon Atanasyan
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [lld] Linker cannot handle sections with non-unique names

shankarke
Thanks Simon.



> On May 24, 2015, at 12:00, Simon Atanasyan <[hidden email]> wrote:
>
> I have committed the patch with added test case at r238115.
> It is better to do not keep a window broken for so long time.
>
>> On Mon, Apr 20, 2015 at 11:49 PM, Rui Ueyama <[hidden email]> wrote:
>> Nothing wrong with going ahead with a temporary measure if the temporary
>> measure is reasonable (besides the discussion if checking in binary files is
>> desirable). Even if you plan to add a test written in YAML, it's better to
>> check in a binary at least for now than checking it in without any tests.
>>
>> On Mon, Apr 20, 2015 at 7:59 AM, Shankar Easwaram <[hidden email]>
>> wrote:
>>>
>>> I plan to add a test case but couldn't add because of yaml2obj support. I
>>> am adding that support to yaml2obj and obj2yaml and push this patch later. I
>>> don't like the idea of adding binary files to the test repo as we need to
>>> keep cleaning up later.
>>>
>>>
>>>
>>>>> On Apr 20, 2015, at 03:34, Simon Atanasyan <[hidden email]> wrote:
>>>>>
>>>>> On Mon, Apr 20, 2015 at 1:44 AM, Shankar Easwaran <[hidden email]>
>>>>> wrote:
>>>>> Attached patch fixes the issue.
>>>>
>>>> Thanks for the quick fix. The patch LGTM if you add a test case.
>>>> Unfortunately yaml2obj does not support duplicated section names but
>>>> we can use a binary input file.
>
> --
> Simon Atanasyan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev