- Jan 10, 2017
-
-
Peter Collingbourne authored
When reserving copy relocation space for a shared symbol, scan the DSO's program headers to see if the symbol is in a read-only segment. If so, reserve space for that symbol in a new synthetic section named .bss.rel.ro which will be covered by the relro program header. This fixes the security issue disclosed on the binutils mailing list at: https://sourceware.org/ml/libc-alpha/2016-12/msg00914.html Differential Revision: https://reviews.llvm.org/D28272 llvm-svn: 291524
-
Peter Collingbourne authored
This is in preparation for my next change, which will introduce a relro nobits section. That requires that relro sections appear at the end of the progbits part of the r/w segment so that the relro nobits section can appear contiguously. Because of the amount of churn required in the test suite, I'm making this change separately. llvm-svn: 291523
-
Rui Ueyama authored
This patch enables something like "-o /dev/null". Previouly, it failed because such files cannot be renamed. Differential Revision: https://reviews.llvm.org/D28010 llvm-svn: 291496
-
- Jan 04, 2017
-
-
Peter Collingbourne authored
The glibc dynamic loader rounds the size down, so without this the loader will fail to change the memory protection for the last page. Differential Revision: https://reviews.llvm.org/D28267 llvm-svn: 290986
-
Peter Collingbourne authored
llvm-svn: 290932
-
- Dec 25, 2016
-
-
George Rimar authored
llvm-svn: 290510
-
- Dec 21, 2016
-
-
Rui Ueyama authored
DefinedSynthetic is not created for a real ELF object, so it doesn't have to be a template function. It has a virtual st_value, which is either 32 bit or 64 bit, but we can simply use 64 bit. llvm-svn: 290241
-
Rui Ueyama authored
llvm-svn: 290215
-
- Dec 20, 2016
-
-
George Rimar authored
That was requested by Mark Kettenis in llvm-dev: "It is the intention that .openbsd.randomdata sections are made read-only after initialization. The native (ld.bfd based) OpenBSD toolchain accomplishes this by including .openbsd.randomdata into the PT_GNU_RELRO segment." He suggested code change, I added testcase. Differential revision: https://reviews.llvm.org/D27974 llvm-svn: 290174
-
Rui Ueyama authored
That variable was of type DenseMap<StringRef, unsigned>, but the unsigned numbers needed to be monotonicly increasing numbers because the implementation that used the variable depended on that fact. That was an implementation detail and shouldn't have leaked into Config. This patch simplifies its type to std::vector<StringRef>. llvm-svn: 290151
-
- Dec 19, 2016
-
-
Rafael Espindola authored
This handles all the corner cases if setting a section address: - If the address is too low, we cannot allocate the program headers. - If the load address is lowered, we have to do that before finalize This also shares some code with the linker script since it was already hitting similar cases. This is used by the freebsd boot loader. It is not clear if we need to support this with a non binary output, but it is not as bad as I was expecting. llvm-svn: 290136
-
George Rimar authored
--retain-symbols-file=filename Retain only the symbols listed in the file filename, discarding all others. filename is simply a flat file, with one symbol name per line. This option is especially useful in environments (such as VxWorks) where a large global symbol table is accumulated gradually, to conserve run-time memory. Note: though documentation says "--retain-symbols-file does not discard undefined symbols, or symbols needed for relocations.", both bfd and gold do that, and this patch too, like testcase show. Differential revision: https://reviews.llvm.org/D27716 llvm-svn: 290122
-
Rafael Espindola authored
llvm-svn: 290115
-
Rui Ueyama authored
Use of CachedHashStringRef makes sense only when we reuse hash values. Sprinkling it to all DenseMap has no benefits and just complicates data types. Basically we shouldn't use CachedHashStringRef unless there is a strong reason to to do so. llvm-svn: 290076
-
- Dec 18, 2016
-
-
Rui Ueyama authored
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 llvm-svn: 290062
-
- Dec 12, 2016
-
-
Simon Atanasyan authored
llvm-svn: 289471
-
- Dec 08, 2016
-
-
Rui Ueyama authored
llvm-svn: 289084
-
Peter Smith authored
This change introduces new synthetic sections IpltSection, IgotPltSection that represent the ifunc entries that would previously have been put in the PltSection and the GotPltSection. The separation makes sure that the R_*_IRELATIVE relocations are placed after the non R_*_IRELATIVE relocations, which permits ifunc resolvers to know that the .got.plt slots will be initialized prior to the resolver being called. A secondary benefit is that for ARM we can move the IgotPltSection and its dynamic relocations to the .got and .rel.dyn as the ARM glibc expects all the R_*_IRELATIVE relocations to be in the .rel.dyn Differential revision: https://reviews.llvm.org/D27406 llvm-svn: 289045
-
Simon Atanasyan authored
These MIPS specific symbols should be global because in general they can have an arbitrary value. By default this value is a fixed offset from .got section. This patch adds more checks to the mips-gp-local.s test case but marks it as XFAIL because LLD does not allow redefinition of absolute symbols value by a linker script. This should be fixed by D27276. Differential revision: https://reviews.llvm.org/D27524 llvm-svn: 289025
-
Rafael Espindola authored
Thanks to George Rimar for pointing it out. llvm-svn: 289020
-
- Dec 07, 2016
-
-
Rafael Espindola authored
llvm-svn: 288971
-
Rafael Espindola authored
Found by inspection. llvm-svn: 288970
-
Rui Ueyama authored
Config->WarnMissingEntry is a single-purpose boolean variable, and I think it's easier to understand than Config->HasEntry. llvm-svn: 288883
-
Rui Ueyama authored
This patch is to parse the entry symbol name lazily. llvm-svn: 288882
-
Petr Hosek authored
Shared libraries should have entry set following the same rules as for regular binaries. The only difference is that in case the default entry point (_start or __start) isn't found (unless it was set explicitly), we shouldn't give a warning as in case of regular binaries. Differential Revision: https://reviews.llvm.org/D27497 llvm-svn: 288878
-
- Dec 06, 2016
-
-
Rafael Espindola authored
If we do, the freebsd dynamic linker tries to call mmap with a size 0, which fails. It is hard to avoid creating them when linker scripts are used, so we just delete empty PT_LOADs at the end. llvm-svn: 288808
-
- Dec 05, 2016
-
-
Rui Ueyama authored
That patch broke build. llvm-svn: 288708
-
Rui Ueyama authored
llvm-svn: 288707
-
Rui Ueyama authored
On Linux (and probably on other Unix-like systems), unlink(2) is noticeably slow. It takes 250 milliseconds to remove a 1 GB file on ext4 filesystem on my machine, whether the file is on SSD or on a spinning disk. To create a new result file, we remove existing file first. So, if you repeatedly link a 1 GB program in a regular compile-link-debug cycle, every cycle wastes 250 milliseconds only to remove a file. Since LLD can link a 1 GB in about 5 seconds, that waste actually matters. This patch defines `unlinkAsync` function. The function spawns a background thread to call unlink. The calling thread returns almost immediately. Differential Revision: https://reviews.llvm.org/D27295 llvm-svn: 288680
-
- Dec 03, 2016
-
-
George Rimar authored
Binary output feature is a bit confuzing. bfd and gold output differs a lot sometimes, though it is important for FreeBSD mbr loaders. Patch change the way how we compute file offsets for binary output. This fixes PR31196. Previously offsets were calculated basing on offsets and addresses of sections from the same loads: if (Sec == First) return alignTo(Off, Target->MaxPageSize, Sec->Addr); return First->Offset + Sec->Addr - First->Addr; bfd assigns offsets for each section to VA - MinVA: https://github.com/redox-os/binutils-gdb/blob/master/bfd/binary.c#L27 https://github.com/redox-os/binutils-gdb/blob/master/bfd/binary.c#L255 (LMA == VA usually) This patch for now just stops creating phdrs for binary output. An effect from this that no any additional calculation for offset is performed: uintX_t getFileAlignment(uintX_t Off, OutputSectionBase *Sec) { OutputSectionBase *First = Sec->FirstInPtLoad; // If the section is not in a PT_LOAD, we have no other constraint. if (!First) return Off; //**First is always null, condition always happens** That is enough now with combination of another patch to generate output that is similar to what bfd produce for mbr loader. Differential revision: https://reviews.llvm.org/D27341 llvm-svn: 288580
-
- Nov 29, 2016
-
-
George Rimar authored
This change continues what was started by D27040 Now all allocatable synthetics should be available from script side. Differential revision: https://reviews.llvm.org/D27131 llvm-svn: 288150
-
George Rimar authored
-N (-omagic) Set the text and data sections to be readable and writable. Also, do not page-align the data segment. Differential revision: https://reviews.llvm.org/D26888 llvm-svn: 288123
-
Eugene Leviant authored
Differential revision: https://reviews.llvm.org/D27097 llvm-svn: 288114
-
- Nov 28, 2016
-
-
George Rimar authored
That unifies handling cases when we have SECTIONS and when -no-rosegment is given in compareSectionsNonScript() Now Config->SingleRoRx is used for check, testcase is provided. llvm-svn: 288022
-
George Rimar authored
--no-rosegment: Do not put read-only non-executable sections in their own segment Differential revision: https://reviews.llvm.org/D26889 llvm-svn: 288020
-
Rafael Espindola authored
Unfortunatelly PT_ARM_EXIDX is special. There is no way to create it from linker scripts, so we have to create it even if PHDRS is used. This matches bfd and is required for the lld output to survive bfd's strip. llvm-svn: 288012
-
- Nov 25, 2016
-
-
George Rimar authored
This is important for cases like: .sdata : { *(.got.plt .got) ... } That was not supported before as there was no way to get access to synthetic sections from script. More details on review page. Differential revision: https://reviews.llvm.org/D27040 llvm-svn: 287913
-
- Nov 24, 2016
-
-
Peter Smith authored
The .ARM.exidx table has an entry for each function with the first entry giving the start address of the function, the table is sorted in ascending order of function address. Given a PC value, the unwinder will search the table for the entry that contains the PC value. If the table entry happens to be the last, the range of the addresses that the final unwinding table describes will extend to the end of the address space. To prevent an incorrect address outside the address range of the program matching the last entry we follow ld.bfd's example and add a sentinel EXIDX_CANTUNWIND entry at the end of the table. This gives the final real table entry an upper bound. In addition the llvm libunwind unwinder currently depends on the presence of a sentinel entry (PR31091). Differential revision: https://reviews.llvm.org/D26977 llvm-svn: 287869
-
Rui Ueyama authored
HasError was always true if ErrorCount > 0, so we can use ErrorCount instead. llvm-svn: 287849
-
- Nov 23, 2016
-
-
Rui Ueyama authored
Previously, if a symbol specified by -e or ENTRY() is not found, we didn't set entry point address. That is incompatible with GNU because GNU linkers set the first address of .text to entry. This patch implement that behavior. llvm-svn: 287836
-