Commit Graph

349 Commits

Author SHA1 Message Date
Jack Andersen 2fa85b9bd4 Merge branch 'master' into small-data 2017-01-27 08:22:12 -10:00
Peter Smith 1a0ca791ab [ELF][ARM] Use SyntheticSections for Thunks
Thunks are now implemented by redirecting the relocation to the
symbol S, to a symbol TS in a Thunk. The Thunk will transfer control
to S. This has the following implications:
- All the side-effects of Thunks happen within createThunks()
- Thunks are no longer stored in InputSections and Symbols no longer
  need to hold a pointer to a Thunk
- The synthetic Thunk sections need to be merged into OutputSections
    
This implementation is almost a direct conversion of the existing
Thunks with the following exceptions:
- Mips LA25 Thunks are placed before the InputSection that defines
  the symbol that needs a Thunk.
- All ARM Thunks are placed at the end of the OutputSection of the
  first caller to the Thunk.
    
Range extension Thunks are not supported yet so it is optimistically
assumed that all Thunks can be reused.

Differential Revision:  https://reviews.llvm.org/D29129



git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293283 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27 13:10:16 +00:00
Rui Ueyama cc622a7000 Remove error(error_code, const Twine &).
Now we have the consistent interface for all log/warn/error/fatal functions.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291847 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 22:18:04 +00:00
Rafael Espindola d4db817fd9 Make the -b binary .data section rw.
This matches what bfd and gold do. It also matches the common flags of
other .data sections.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291674 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-11 15:13:05 +00:00
Peter Collingbourne 5720cb6774 ELF: Discard .gnu.linkonce.* sections.
The linkonce feature is a sort of proto-comdat. As far as I am aware no
compiler produces linkonce sections anymore, but some glibc i386 object
files contain definitions of symbol "__x86.get_pc_thunk.bx" in linkonce
sections. Drop those sections to avoid duplicate symbol errors.

This is glibc PR20543, we should remove this hack once that has been
fixed for a while.

Fixes PR31215.

Differential Revision: https://reviews.llvm.org/D28430

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291474 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-09 20:26:33 +00:00
Rui Ueyama 68320f36fa Add linker-script-included files to reproduce tar files.
Previously, files added using INCLUDE directive weren't added
to reproduce archives. In this patch, I defined a function to
open a file and use that from Driver and LinkerScript.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291413 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-09 01:42:02 +00:00
Rafael Espindola d45843c2ba Handle versioned undefined symbols.
In order to keep symbol lookup a simple name lookup this patch adds
versioned symbols with an explicit @ to the symbol table.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291293 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 22:30:35 +00:00
Rui Ueyama 83d4f18a3b Merge elf::toString and coff::toString.
The two overloaded functions hid each other. This patch merges them.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291222 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 10:04:08 +00:00
Rui Ueyama 1d3f65a290 Use \ as the path separator on Windows.
Previously, when we printed out a path obtained from DWARF debug info,
we replaced \ with / on Windows. But that doesn't make sense. We should
respect the system's path separator.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291219 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 08:59:32 +00:00
Rui Ueyama 03c1d58f2f Use TarWriter to create tar archives instead of cpio.
This is how we use TarWriter in LLD. Now LLD does not append
a file extension, so you need to pass `--reproduce foo.tar`
instead of `--reproduce foo`.

Differential Revision: https://reviews.llvm.org/D28103

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291210 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 02:33:53 +00:00
Peter Smith 5e37fda1d7 [ELF] Add support for thunks to undefined non-weak symbols
In a shared library an undefined symbol is implicitly imported. If the
symbol is called as a function a PLT entry is generated for it. When the
caller is a Thumb b.w a thunk to the PLT entry is needed as all PLT
entries are in ARM state.
    
This change allows undefined symbols to have thunks in the same way that
shared symbols may have thunks.



git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290951 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 09:45:45 +00:00
Rui Ueyama 54b01a52e8 Remove lld/Support/Memory.h.
I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

Differential Revision: https://reviews.llvm.org/D27819

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-18 14:06:06 +00:00
Peter Smith c6fa7e55d3 [ELF] Accept first SHT_ARM_ATTRIBUTES section
The eglibc library, as used by Ubuntu 14.04 requires the presence of an
SHT_ARM_ATTRIBUTES section in for the purposes of checking hard/soft float
compatibility when dlopen() is used. Unfortunately when the section is not
present dlopen() fails with a generic could not find file message.
    
This change makes lld keep the first .ARM.attributes section that it
encounters and propagates it to the output. This is not a complete
SHT_ARM_ATTRIBUTES implementation, that would involve reading the contents
of the section and joining each individual attribute. It should suffice
for a homogenous build all libraries and executables on the same system
with a compatible set of command line options.

Differential revision: https://reviews.llvm.org/D27718



git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289642 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 10:36:12 +00:00
Rui Ueyama ca7af8d122 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 18:31:13 +00:00
Rui Ueyama bb17562db0 Remove redundant call of std::unique_ptr::get.
Obj is an instance of std::unique_ptr, so *Obj.get() is the same as *Obj.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288996 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 23:26:39 +00:00
Rui Ueyama 9741c1894b Do not pass line number to convertToUnixPathSeparator.
Line number can never contain '/' or '\', so the previous code
was pointless at that point.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288973 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 20:25:45 +00:00
Rui Ueyama 28293a5dce Make convertToUnixPathSeparator return a new string instead of mutating argument.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288972 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 20:22:27 +00:00
George Rimar 3f2e818bb7 Format. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288967 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 19:44:27 +00:00
George Rimar aab8f2ab8e [ELF] - Print absolute file name in errors when possible.
Currently LLD prints basename of source file name in error messages,
for example:
$ mkdir foo
$ echo 'void _start(void) { foobar(); }' > foo/bar.c
$ gcc -g -c foo/bar.c
$ bin/ld.lld -o out bar.o 
bin/ld.lld: error: bar.c:1: undefined symbol 'foobar'
$
This should say:
bin/ld.lld: error: foo/bar.c:1: undefined symbol 'foobar'

This is PR31299

Differential revision: https://reviews.llvm.org/D27506

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288966 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 19:42:25 +00:00
Jack Andersen 89f2cd22cb Merge branch 'master' into small-data 2016-11-29 15:51:44 -10:00
Rui Ueyama 4b58d6990f Use StringRefZ explicitly instead of const char *.
This patch is to avoid an implicit conversion from const char * to
StringRefZ, to make it apparent where we are using StringRefZ.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288182 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29 19:11:39 +00:00
Rui Ueyama a2caa8e66e Introduce StringRefZ class to represent null-terminated strings.
StringRefZ is a class to represent a null-terminated string. String
length is computed lazily, so it's more efficient than StringRef to
represent strings in string table.

The motivation of defining this new class is to merge functions
that only differ in string types; we have many constructors that takes
`const char *` or `StringRef`. With StringRefZ, we can merge them.

Differential Revision: https://reviews.llvm.org/D27037

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288172 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29 18:05:04 +00:00
Jack Andersen 2088a6f644 Merge branch 'master' into small-data 2016-11-25 09:42:36 -10:00
Rui Ueyama f81ed0ab91 Move typedefs inside a class definition.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-25 18:51:56 +00:00
Rui Ueyama c01599fd35 Define toString() as a generic function to get a string for error message.
We have different functions to stringize objects to construct
error messages. For InputFile, we have getFilename, and for
InputSection, we have getName. You had to memorize them.

I think this is the case where the function overloading comes in handy.

This patch defines toString() functions that are overloaded for all these
types, so that you just call it in error().

Differential Revision: https://reviews.llvm.org/D27030

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287787 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23 18:07:33 +00:00