This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] x86-64: Resolve R_X86_64_PLT32 referencing a local symbol even if defined in another section


On 2020-02-13, H.J. Lu wrote:
On Wed, Feb 12, 2020 at 11:25 PM Fangrui Song <maskray@google.com> wrote:

See gas/testsuite/gas/i386/relax-5.s
Currently gas incorrectly emits a .L symbol.
Context: https://github.com/ClangBuiltLinux/linux/issues/811

(begin story

I taught clang to emit a call insn referencing a local symbol if the
symbol is defined in the same translation unit. This can avoid unneeded
PLT if the object file is linked with -shared.

Why does a linker generate a PLT entry for PLT32 relocation against a local
symbol?  Does BFD linker have the same issue?

The problem is not a linker, but objtool (used by the Linux kernel)'s
unneeded constraint on st_type.

GNU as emits an R_X86_64_PLT32 for `call .Lprintk$local`.

I think this is fine, and actually my preference for a call/jump instruction,
because PLT32 indicates that the address of the target function is not significant.
The linker should optimize it as if a PC32 if the symbol is
non-preemptible.

On the other hand, PC32 can mean the address is taken. Though it does
not matter when used on a local defined symbol (guaranteed
non-preemptible).

.globl foo
foo:
.Lfoo$local:
...
  call .Lfoo$local
end story)

The test case x86-64-relax-5.d is almost correct, except the last line.
I cannot figure out how to make runtest accept the last line.
runtest is so rigid about whitespace and newlines.
<printk> is not significant to the test, but I have to include it,
otherwise runtest will complain.

This is how I run tests:

% cd ~/Dev/binutils-gdb/Release/gas
% runtest -v --tool gas --srcdir ../../gas/testsuite/ i386.exp

This command runs a number of unrelated test cases. Is it very difficult to
run an isolated test case? This will be super helpful when developing a
bug fix.


It is hard to do since i386.exp doesn't use wild card.

Thanks for the explanation. This topic (dejagnu is very inconvenient) may deserve its own topic.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]