Commit Graph

3155 Commits

Author SHA1 Message Date
Davide Italiano 06b21daf00 Revert unrelated chunk committed by accident in r236334.
The change is likely to be correct, but unrelated to the aforementioned
commit and needs a test to gets shipped. Sorry.

llvm-svn: 236336
2015-05-01 19:24:29 +00:00
Davide Italiano 9de946fa1f [ELF] Fix test for .init_array.
Change the test so that it tests the right functionality.
Also put a description with the code from which the test was generated.
Reported by Simon Atanasysan.

llvm-svn: 236334
2015-05-01 19:20:48 +00:00
Simon Atanasyan 097c21520e [Mips] Check creation of GOT entries corresponded to R_MIPS_REL32 relocations
No functional changes.

llvm-svn: 236314
2015-05-01 13:41:45 +00:00
Davide Italiano 312b15adb9 Change test target from x86_64-linux to x86_64.
llvm-svn: 236293
2015-05-01 00:36:41 +00:00
Davide Italiano 0e4a3addf0 [ELF] Mark linker defined symbols as .hidden when needed.
I noticed that gold mark these as hidden. While at it I rewrote the test for
this feature to use yaml rather than an object file as input.

Differential Revision:	http://reviews.llvm.org/D9418
Reviewed by:	ruiu

llvm-svn: 236291
2015-05-01 00:07:11 +00:00
Davide Italiano f14fbcbf91 [GNU] Remove -x/-X from the list of options to be implemented.
llvm-svn: 236149
2015-04-29 20:35:58 +00:00
Rafael Espindola ed48e53d60 Use MemoryBufferRef instead of MemoryBuffer&. NFC.
This just reduces the noise from another patch.

llvm-svn: 235933
2015-04-27 22:48:51 +00:00
Rui Ueyama 035025c0da Remove trailing whitespace characters.
llvm-svn: 235897
2015-04-27 17:18:04 +00:00
Rui Ueyama de9215e498 ELF: Simplify LinkerScript detection. NFC.
llvm-svn: 235895
2015-04-27 16:54:48 +00:00
Adhemerval Zanella d31aadf515 Add missing snippets from r235880
llvm-svn: 235890
2015-04-27 15:13:17 +00:00
Adhemerval Zanella 6bf4da02c1 ELF/ARM: Ignore R_ARM_V4BX for ARMv4 but allow linking
This patch allow the ARM relocation R_ARM_V4BX to be processed by lld,
although it is not really handled in the static relocation code.  The
relocation is in the form:

Relocation section '.rel.text' at offset 0x428 contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000014  00000028 R_ARM_V4BX

Meaning it does have a direct target, but rather references to an absolute
section *ABS* (in this exemple to the .text segment itself).  It makes the
target Atom after file parse to not have a associated pointer and thus
generating a derrefence NULL point in ELFFile<ELFT>::findAtom.  Current
approach is just ignore and return nullptr in such cases.

The problem relies that default GCC configuration
for arm-linux-gnueabi{hf} emits the relocation for the asm:

--
.syntax unified
.arm

.p2align 2
.type fn, %function
fn:
  ldr r3, .LGOT
  ldr r2, .LGOT+4
.LPIC:
  add r3, pc, r3
  ldr r2, [r3, r2]
  cmp r2, #0
  bxeq lr
  b __start__
.LGOT:
 .word _GLOBAL_OFFSET_TABLE_-(.LPIC+8)
 .word __start__(GOT)
--

But only with the option -march=armv4 (which is the default GCC configuration).
For arm5 and forward the relocation is not created. This a special relocation
(defined miscellaneous for ARM) that instruct the linker to replace the bx
instruction into a mov.  GNU linker has some options related to which substitution
it can create for such cases.

With this patch I can dynamically link an application against a GLIBC
arm-linux-gnueabi system configured with default GCC.

llvm-svn: 235880
2015-04-27 13:55:14 +00:00
Rafael Espindola 6759319c3c Use MemoryBufferRef instead of MemoryBuffer&. NFC.
This just reduces the noise from another patch.

llvm-svn: 235776
2015-04-24 21:10:50 +00:00
Rafael Espindola b597408da4 Simplify parseMemberFiles to take a single file.
llvm-svn: 235751
2015-04-24 19:08:51 +00:00
Rafael Espindola 773a159116 Simplify now that there is only one file. NFC.
llvm-svn: 235747
2015-04-24 19:01:30 +00:00
Rafael Espindola ab5696ba82 Return ErrorOr<std::unique_ptr<File>>. NFC.
llvm-svn: 235744
2015-04-24 18:51:30 +00:00
Rafael Espindola c1d535af05 Remove unused enum value. NFC.
llvm-svn: 235742
2015-04-24 18:36:57 +00:00
Rafael Espindola dedab912c3 Return an ErrorOr<std::unique_ptr<File>>. NFC.
llvm-svn: 235741
2015-04-24 18:33:50 +00:00
Davide Italiano 75e1172b19 [Test] Explictly pass target architecture.
If we're not being explicit, the test fails on windows.
Reported and tested by Aaron Ballman!

llvm-svn: 235739
2015-04-24 18:18:34 +00:00
Rafael Espindola c08ab8e6e4 Delete unnecessary generality in loadFile.
loadFile could load mulitple files just because yaml has a feature for
putting multiple documents in one file.

Designing a linker around what yaml can do seems like a bad idea to
me. This patch changes it to read a single file.

There are further improvements to be done to the api and they
will follow shortly.

llvm-svn: 235724
2015-04-24 15:51:45 +00:00
Simon Atanasyan e10a258527 [Mips] Simplify the code a bit using early return
No functional changes.

llvm-svn: 235708
2015-04-24 11:14:24 +00:00
Denis Protivensky 87d935dd09 [ARM] Update TODO notes
llvm-svn: 235706
2015-04-24 09:55:11 +00:00
Denis Protivensky c3431bf67b [ARM] Implement R_ARM_COPY relocation
This adds support of copying objects from shared libraries.

llvm-svn: 235705
2015-04-24 08:53:02 +00:00
Leny Kholodov 592cee666e [ARM] Update R_ARM_TARGET1 command line option names (remove prefix 'arm-')
Command line options --arm-target1-rel and --arm-target1-abs have been renamed to be compatible with GNU linkers.
Two tests have been updated:
  test/elf/options/target-specific-args.test
  test/elf/ARM/rel-arm-target1.test

Differential Revision: http://reviews.llvm.org/D9037

llvm-svn: 235499
2015-04-22 11:58:09 +00:00
Leny Kholodov 9e4292c0ec [ARM] Replace branches to undefined weak functions with NOP
According to the code model (ARM, Thumb, Thumb2) this patch updates the b/bl/blx 0 instructions with NOP.
test/elf/ARM/weak-branch.test has been added with tests for all available NOP (A1, T1, T2 encodings).

Differential Revision: http://reviews.llvm.org/D8807

llvm-svn: 235498
2015-04-22 11:47:53 +00:00
Simon Atanasyan 6668eb3c40 [Mips] Assign .MIPS.options section to the PT_LOAD segment
llvm-svn: 235488
2015-04-22 08:09:38 +00:00
Simon Atanasyan 5606dac67e [ELF] Allow TargetLayout descendants to control assignment sections to segments
The TargetLayout class puts two sections into the same segment if they
have equal segment types and the same section flags (SHF_xxx). To be
able to merge some sort of sections into the same segment we drop some
flags before comparison. For example to merge string sections into Data
segment we drop SHF_STRINGS and SHF_MERGE flags.

The patch allows TargetLayout descendants to drop some target specific
section flags. MIPS target needs that to merge .MIPS.options section
which has SHF_MIPS_NOSTRIP flag into the LOAD segment.

http://reviews.llvm.org/D9160

llvm-svn: 235487
2015-04-22 07:57:35 +00:00
Denis Protivensky 4b0abddeea [ARM] Implement veneers for dynamic executable linking
llvm-svn: 235486
2015-04-22 07:51:26 +00:00
Denis Protivensky f6c8938edd [ARM] Move veneer generators to base class. NFC
llvm-svn: 235485
2015-04-22 07:45:55 +00:00
Denis Protivensky 38b09f529c [ARM] Rename static veneer atoms to absolute code veneer atoms
No functional changes.

llvm-svn: 235484
2015-04-22 07:38:47 +00:00
Simon Atanasyan acd58af7df [ELF] Change return type of the OutputSection::flags() method
This method returns _flags field which has `uint64_t` type. Now the
field's type and the method's return type are consistent.

llvm-svn: 235393
2015-04-21 17:02:49 +00:00
Simon Atanasyan 72026b013b [ELF] Narrow down the type of OutputSection::_sections container
The `OutputSection::appendSection()` method always gets a pointer
to the `Section` class descendants. So it is not necessary to keep them
in the vector of `Chunk` pointers.

No functional changes.

llvm-svn: 235392
2015-04-21 17:02:42 +00:00
Simon Atanasyan fcb19e19d0 [Mips] Write .reginfo section into the separate PT_MIPS_REGINFO segment
llvm-svn: 235391
2015-04-21 17:02:35 +00:00
Simon Atanasyan d64f8a5188 [ELF] Simplify class memeber function declaration
No functional changes.

llvm-svn: 235390
2015-04-21 17:02:27 +00:00
Davide Italiano 037cfdd1db --discard-locals should be --discard-all here.
Sorry for the mistake/confusion.

llvm-svn: 235359
2015-04-20 22:54:50 +00:00
Davide Italiano 30326b9d8f [GNU/ELF] Add support for -X/--discard-locals.
There's (almost) never need to keep .L symbols around for production
builds. In fact, the FreeBSD kernel explicitly specify -X beacuse the
size impact (and the subsequent performance impact) might be significant,
because we keep symbols in memory.
I was tempted to make this the default, but I haven't (yet).

PR:		23232
llvm-svn: 235357
2015-04-20 22:52:56 +00:00
Simon Atanasyan 84adf3ff15 [Mips] Write DT_MIPS_OPTIONS tag to .dynamic section
If .MIPS.options section exists the DT_MIPS_OPTIONS tag should hold
an address of this section.

llvm-svn: 235290
2015-04-20 07:36:27 +00:00
Simon Atanasyan 8119228977 [Mips] Support R_MICROMIPS_PC18_S3/PC19_S2/PC21_S2/PC26_S2 relocations handling
llvm-svn: 235289
2015-04-20 07:34:52 +00:00
Simon Atanasyan 41ce98cc6f [Mips] Support R_MICROMIPS_GOT_DISP / PAGE / OFST relocations handling
llvm-svn: 235288
2015-04-20 07:33:02 +00:00
Davide Italiano 3d9e582a46 Accept --dynamic-linker <file>.
Before we only accepted --dynamic-linker=<file> and -dynamic-linker <file>
but older versions of GNU ld (e.g. 2.17.50) accept this other form, so
try to be compatible.

PR:		23233
llvm-svn: 235282
2015-04-19 23:45:41 +00:00
Davide Italiano 9a5b990f27 [GNU/ELF] Add support for -x/--discard-all.
PR:		23232
llvm-svn: 235247
2015-04-18 00:32:38 +00:00
Rui Ueyama e47aca8a6c Delete dead code (again).
llvm-svn: 235217
2015-04-17 18:58:34 +00:00
Rui Ueyama 3ff1170e5e Delete dead code.
llvm-svn: 235216
2015-04-17 18:54:29 +00:00
Rui Ueyama 1620a334ba Use C++11 non-static member initialization.
llvm-svn: 235187
2015-04-17 12:53:16 +00:00
Denis Protivensky 0575c5de68 [ARM] Implement R_ARM_TLS_IE32 for dynamic executable
llvm-svn: 235182
2015-04-17 11:30:29 +00:00
Denis Protivensky 3b5f7e9965 [ARM] Test R_ARM_TLS_LE32 for dynamic executable
llvm-svn: 235180
2015-04-17 11:24:11 +00:00
Simon Atanasyan 6313038925 [Mips] Make tests more tolerant to offsets, symbol sizes etc
No functional changes.

llvm-svn: 235035
2015-04-15 18:32:22 +00:00
Simon Atanasyan 09129d957c [Mips] clang-format the code
llvm-svn: 235033
2015-04-15 18:32:05 +00:00
Simon Atanasyan f4a87333ff [Mips] Remove redundant `.got` section lookup
No functional changes.

llvm-svn: 235032
2015-04-15 18:31:59 +00:00
Simon Atanasyan 834632cd1a [Mips] Create _GLOBAL_OFFSET_TABLE_ only if the .got section exists
llvm-svn: 235031
2015-04-15 18:31:53 +00:00
Simon Atanasyan fa21338a97 [Mips] Check `_gp_disp` symbol using a trivial string comparison
No functional changes.

llvm-svn: 235030
2015-04-15 18:31:44 +00:00