[PATCH] [InputGraph][Gnu] Add Linkerscript support.
Shankar Kalpathi Easwaran
shankarke at gmail.com
Tue Nov 19 20:36:34 PST 2013
Hi Bigcheese, kledzik, ruiu,
This adds new functionality in the InputGraph to parse LinkerScripts.
a) Adds support to expand nodes in the InputGraph.
b) Support for Hidden nodes(Nodes that are internal to the InputGraph, and not part of resolution and parsing).
c) Adds a GnuLdScript/ELFGNULdScript node.
With this dynamic glibc helloworld runs fine(dynamic 'C').
As mentioned earlier by Bigcheese, it also links with libstdc++ with appropriate relocations (dynamic) but fails to run.
<-----------------snip---------------->
$type g++
g++ is hashed (/usr/bin/g++)
$cat a.cpp
#include <iostream>
#include <stdio.h>
class A{
public:
A() {
std::cout << "A" << std::endl;
}
~A() {
std::cout << "~A" << std::endl;
}
};
int main()
{
A a;
return 0;
}
$g++ -B`pwd` a.cpp
lld -flavor gnu --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr2/seaswara/tests/lld/extratests/dyncpp -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. /tmp/ccPK1vpI.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/crtn.o
$readelf -r a.out
Relocation section '.rela.dyn' at offset 0x796 contains 1 entries:
Offset Info Type Sym. Value Sym. Name + Addend
0000004b0298 000100000005 R_X86_64_COPY 00000000004b0298 _ZSt4cout + 0
Relocation section '.rela.plt' at offset 0x7ae contains 18 entries:
Offset Info Type Sym. Value Sym. Name + Addend
0000004ac248 000d00000007 R_X86_64_JUMP_SLO 0000000000000000 _Unwind_Resume + 0
0000004ac250 000300000007 R_X86_64_JUMP_SLO 0000000000000000 _ZNSt8ios_base4InitC1E + 0
0000004ac258 000500000007 R_X86_64_JUMP_SLO 0000000000000000 _ZNSt8ios_base4InitD1E + 0
0000004ac260 000200000007 R_X86_64_JUMP_SLO 0000000000000000 _ZStlsISt11char_traits + 0
0000004ac268 000600000007 R_X86_64_JUMP_SLO 0000000000000000 _ZSt4endlIcSt11char_tr + 0
0000004ac270 000700000007 R_X86_64_JUMP_SLO 0000000000000000 _ZNSolsEPFRSoS_E + 0
0000004ac278 000800000007 R_X86_64_JUMP_SLO 0000000000000000 __gxx_personality_v0 + 0
0000004ac280 000000000025 R_X86_64_IRELATIV 0000000000419300
0000004ac288 001700000007 R_X86_64_JUMP_SLO 0000000000000000 __gcc_personality_v0 + 0
0000004ac290 000000000025 R_X86_64_IRELATIV 0000000000413860
0000004ac298 000000000025 R_X86_64_IRELATIV 000000000042ef10
0000004ac2a0 000000000025 R_X86_64_IRELATIV 0000000000421140
0000004ac2a8 000000000025 R_X86_64_IRELATIV 000000000042b520
0000004ac2b0 000000000025 R_X86_64_IRELATIV 0000000000432ba0
0000004ac2b8 000000000025 R_X86_64_IRELATIV 00000000004668e0
0000004ac2c0 000000000025 R_X86_64_IRELATIV 0000000000464e50
0000004ac2c8 001900000007 R_X86_64_JUMP_SLO 0000000000000000 _Unwind_Backtrace + 0
0000004ac2d0 001800000007 R_X86_64_JUMP_SLO 0000000000000000 _Unwind_GetIP + 0
$./a.out
unexpected reloc type in static binaryAborted
<------------------snip----------------->
http://llvm-reviews.chandlerc.com/D2225
Files:
include/lld/Core/Error.h
include/lld/Core/File.h
include/lld/Core/InputGraph.h
include/lld/Core/LinkingContext.h
include/lld/Driver/GnuLdInputGraph.h
include/lld/ReaderWriter/ELFLinkingContext.h
include/lld/ReaderWriter/ReaderLinkerScript.h
lib/Core/Error.cpp
lib/Core/InputGraph.cpp
lib/Core/Resolver.cpp
lib/Driver/CMakeLists.txt
lib/Driver/Driver.cpp
lib/Driver/GnuLdDriver.cpp
lib/Driver/GnuLdInputGraph.cpp
lib/ReaderWriter/CMakeLists.txt
lib/ReaderWriter/ELF/ELFLinkingContext.cpp
lib/ReaderWriter/ReaderLinkerScript.cpp
unittests/DriverTests/GnuLdDriverTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2225.1.patch
Type: text/x-patch
Size: 29154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131119/546583b4/attachment.bin>
More information about the llvm-commits
mailing list