Commit Graph

3168 Commits

Author SHA1 Message Date
Davide Italiano d3142ec82b [ARM] Use the correct variable name and unbreak buildbot.
llvm-svn: 236880
2015-05-08 16:49:18 +00:00
Leny Kholodov bde4144338 [ARM] Generation of .ARM.exidx/.ARM.extab sections
This patch provides generation of .ARM.exidx & .ARM.extab sections which are
used for unwinding. The patch adds new content type typeARMExidx for atoms from
.ARM.exidx section and integration of atoms with such type to the ELF
ReaderWriter. exidx.test has been added with checking of contents of .ARM.exidx
section and .ARM.extab section.

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

llvm-svn: 236873
2015-05-08 16:04:11 +00:00
Denis Protivensky 679c2c3639 [ARM] Check overflow of R_ARM_THM_JUMP11
llvm-svn: 236842
2015-05-08 12:45:11 +00:00
Denis Protivensky 73e927885c [ARM] Check overflow of R_ARM_CALL/JUMP24
llvm-svn: 236841
2015-05-08 12:36:40 +00:00
Denis Protivensky a0cffffcfa [ARM] Check overflow of R_ARM_THM_CALL/JUMP24
llvm-svn: 236839
2015-05-08 12:34:43 +00:00
Simon Atanasyan cb9547b941 [ELF] Initialize the _outputMagic class field using default value
No functional changes.

llvm-svn: 236823
2015-05-08 10:48:30 +00:00
Simon Atanasyan 668977f666 [Mips] Update test cases to reflect changes in the yaml2obj tool
No functional changes.

llvm-svn: 236742
2015-05-07 16:24:09 +00:00
Denis Protivensky 1a3bd31e52 [ARM] Check overflow of R_ARM_PREL31
llvm-svn: 236729
2015-05-07 14:05:30 +00:00
Denis Protivensky cf4e031b36 [ARM] llvm_unreachable => make_dynamic_error in R_ARM_BASE_PREL
llvm-svn: 236727
2015-05-07 13:44:51 +00:00
Denis Protivensky aaeba9ebb9 [ARM] llvm_unreachable => make_*_reloc_error in group relocs
llvm-svn: 236726
2015-05-07 13:41:44 +00:00
Denis Protivensky bc11ba4061 [ARM] Return directly from switch in relocation handler
llvm-svn: 236724
2015-05-07 13:12:11 +00:00
Denis Protivensky 9c3738ccef [ARM] Add return codes to relocation handlers
llvm-svn: 236723
2015-05-07 12:44:20 +00:00
Simon Atanasyan 1c55a071fd [Mips] Add more checkings to the test
No functional changes.

llvm-svn: 236391
2015-05-02 21:03:00 +00:00
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