[llvm-dev] llc tool followed by g++ : Abnormal behavior while compiling assembly to object file

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 23 03:40:28 PDT 2018


Hi Mahesh,

On 23 April 2018 at 10:51, Mahesh Attarde via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> movq .str at GOTPCREL(%rip),%rdi
> movq .str.1 at GOTPCREL(%rip),%rsi

That's quite strange. You wouldn't normally expect to access a
constant string via the GOT. It looks like LLVM has decided to put the
symbols in an odd section, so it'd be a good idea to make sure your
entire triple matches GCC (e.g. -mtriple=x86_64-linux-gnu or
x86_64-apple-macosx or whatever).

> mov  0x0(%rip),%rdi
> mov  0x0(%rip),%rsi

Is this really at runtime, or are you inspecting the .o file? If it's
the .o file this is pretty normal. GCC will have recorded a bunch of
relocations in a different place, telling the linker how to fix these
accesses up so they really do end up pointing to different strings.
"objdump -rd" would print them alongside the disassembly.

If it's at runtime, you still want to look at the object file to find
out whether it's GCC or your linker that's made the mistake (or LLVM,
of course; maybe it's not just me that was surprised by the llc
output, but GCC couldn't cope either).

Cheers.

Tim.


More information about the llvm-dev mailing list