Commit Graph

401 Commits

Author SHA1 Message Date
Igor Kudrin 65bddeaacf [ELF2] Check for TLS mismatch in symbol resolution.
The linker should generate an error if a TLS symbol is resolved
for a non-TLS reference and vice versa.

The patch addresses PR24244 (https://llvm.org/bugs/show_bug.cgi?id=24244)

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

llvm-svn: 249817
2015-10-09 09:58:39 +00:00
George Rimar b352b9ce69 [ELF2] - Implemented rel[a].plt sections
.rela.plt contains list of elements in the PLT, which are liable to the relocation during the dynamic linking.

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

llvm-svn: 249816
2015-10-09 09:58:08 +00:00
Rui Ueyama fe7eeed585 ELF2: Sort. NFC.
llvm-svn: 249803
2015-10-09 02:46:28 +00:00
Rui Ueyama 36f69229e6 Simplify expressions. NFC.
llvm-svn: 249793
2015-10-09 00:50:05 +00:00
Rui Ueyama 49c68a7cf7 Remove getters/setters that don't provide much abstraction.
llvm-svn: 249791
2015-10-09 00:42:06 +00:00
Rui Ueyama 964ffb3e11 Define --output= as an alias to -o.
llvm-svn: 249789
2015-10-09 00:33:44 +00:00
Rui Ueyama 5a9640be32 ELF2: Split Writer::createSections into small functions.
Also added a few comments.

llvm-svn: 249781
2015-10-08 23:49:30 +00:00
Rui Ueyama 00851fdf4c Use uintX_t instead of unsigned int to fix potential cross-linking issue.
llvm-svn: 249765
2015-10-08 22:43:55 +00:00
Hal Finkel e3c2626aa4 [ELF2] Make the system page size a target-dependent property
The required page alignment is different on different targets. On PowerPC, for
example, we need 64K pages (the loader won't set different permissions on a
finer granularity than that). I've set the existing targets to what I believe
to be the correct values, and have updated the regression tests accordingly.

llvm-svn: 249760
2015-10-08 22:23:54 +00:00
Hal Finkel 6c2a3b8368 [ELF2] Make the .plt entry size target dependent
The size of a .plt entry is different on different targets (it is,
specifically, much larger than 8 on all PPC ABIs). There is no functional
change here (later patches to create .plt entries for PPC64 will depend on this
change).

llvm-svn: 249756
2015-10-08 21:51:31 +00:00
Hal Finkel 4729064a1c Revert: r249728 - Roll back r249726 and r249723 because they broke buildbots.
Reapply r249726 (and r249723), hopefully with the correct test fixups this time.

Original commit message:

Address a FIXME in ELF/Writer.cpp: Make VAStart a target-dependent property.
I've set the values for the existing targets to what I believe to be the
correct values, and updated the regression tests accordingly.

llvm-svn: 249752
2015-10-08 21:25:04 +00:00
Rafael Espindola 6390d16fd1 Don't silently ignore an error.
Found by inspection.

llvm-svn: 249744
2015-10-08 20:43:19 +00:00
Rafael Espindola 98af66f9c5 Make this test a bit stricter.
The only way for SecIndex to be zero in here is for an extended section
number to be zero, which would be an error.

llvm-svn: 249736
2015-10-08 20:29:22 +00:00
Rui Ueyama af21d92320 ELF2: Do not pass GotVA because it's accessible as Out<ELFT>::Got->getVA().
llvm-svn: 249729
2015-10-08 20:06:07 +00:00
Rui Ueyama 7114f0597b Roll back r249726 and r249723 because they broke buildbots.
llvm-svn: 249728
2015-10-08 20:00:02 +00:00
Hal Finkel eb84ce8bd1 [ELF2] Make VAStart a target-dependent property
Address a FIXME in ELF/Writer.cpp: Make VAStart a target-dependent property.
I've set the values for the existing targets to what I believe to be the
correct values, and updated the regression tests accordingly.

llvm-svn: 249723
2015-10-08 19:36:39 +00:00
Hal Finkel cbd21a6ad2 [ELF2] Use EntrySize, not 8, to advance the .plt buffer when writing
In preparation for making the size of a .plt entry target dependent, use the
existing EntrySize variable when writing (instead of a hard-coded value). NFC.

llvm-svn: 249720
2015-10-08 19:16:05 +00:00
Davide Italiano 68a39a6565 [ELF2] Implement linker script SEARCH_DIR() directive.
llvm-svn: 249707
2015-10-08 17:51:41 +00:00
Simon Atanasyan 456bd05d97 [ELF2][mips] Support elf32ltsmip/elf32btsmip target emulation as the -m arguments
llvm-svn: 249683
2015-10-08 12:13:38 +00:00
Rafael Espindola d42f4e5389 Add a convenience variable. NFC.
llvm-svn: 249682
2015-10-08 12:02:38 +00:00
Denis Protivensky 90c5099e8a [ELF2] Add ENTRY command to the linker script
Set ENTRY as an entry point if -e is not specified.

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

llvm-svn: 249661
2015-10-08 06:48:38 +00:00
Rui Ueyama 10c415fd63 Remove a default which immediately breaks.
getID()'s return type is unsigned int, so I don't think we need this
default for -Wswitch-enum.

llvm-svn: 249650
2015-10-08 03:21:29 +00:00
Rui Ueyama aca48ffb41 ELF2: Inititalize other symbols only once as well.
llvm-svn: 249645
2015-10-08 00:44:28 +00:00
Rui Ueyama 833ce281db ELF2: Make member variable names shorter.
I'm going to use them in other patches, and the names feel too long
despite their narrow scope.

llvm-svn: 249642
2015-10-08 00:29:00 +00:00
Rui Ueyama 9ea49c7948 ELF2: Initialize SyntheticOptional only once.
llvm-svn: 249636
2015-10-07 23:46:11 +00:00
Rui Ueyama e66e001c90 ELF2: Use the same name as COFF.
llvm-svn: 249635
2015-10-07 23:20:23 +00:00
Davide Italiano c3858ab82e [ELF2] Garbage collect or{16,64}le. They're now unused.
llvm-svn: 249628
2015-10-07 22:11:20 +00:00
Davide Italiano 06d843226b [ELF2/AArch64] _ABS* relocations don't read contents. Fix it.
Spotted by: Rafael Espindola.

llvm-svn: 249627
2015-10-07 22:10:02 +00:00
Rui Ueyama e1f91529c8 ELF2: Rename dupError() -> reportConflict().
llvm-svn: 249622
2015-10-07 21:37:24 +00:00
Rui Ueyama 0d0bcf7433 ELF2: Stop using SymbolTableSection as a container for SymbolTable.
`Symtab` is better than `Out<ELFT>::SymTab->getSymTable()`.

llvm-svn: 249619
2015-10-07 21:25:39 +00:00
Rui Ueyama 2cac5843a0 ELF2: Define a utility function to handle simple command line options.
llvm-svn: 249592
2015-10-07 19:34:51 +00:00
Rui Ueyama 15ef5e174b ELF2: Make singleton output sections globally accessible.
Previously, output sections that are handled specially by the linker
(e.g. PLT or GOT) were created by Writer and passed to other classes
that need them. The problem was that because these special sections
are required by so many classes, the plumbing work became too much
burden.

This patch is to simply make them accessible from anywhere in the
linker to eliminate the plumbing work once and for all.

http://reviews.llvm.org/D13486

llvm-svn: 249590
2015-10-07 19:18:16 +00:00
George Rimar 730c27894a [ELF2] - fix to use PLT/GOT for DSO function calls (X86TargetInfo)
Differential Revision: http://reviews.llvm.org/D13522

llvm-svn: 249588
2015-10-07 18:46:13 +00:00
Rui Ueyama 75230398c2 ELF2: De-templatize writeResult for simplicity.
llvm-svn: 249586
2015-10-07 18:29:51 +00:00
Rui Ueyama 58d7d704d8 Style fix.
llvm-svn: 249584
2015-10-07 18:22:46 +00:00
Rui Ueyama b4908761f8 ELF2: Rename local variable name `Out` in preparation to define `Out` global var.
llvm-svn: 249568
2015-10-07 17:04:18 +00:00
Rui Ueyama 0db335fd5e ELF2: Move functions out of line.
llvm-svn: 249566
2015-10-07 16:58:54 +00:00
George Rimar 97aad172b8 [ELF2] -z now option implemented
When generating an executable or shared library, mark it to tell the dynamic linker to resolve all symbols when the program is started, or when the shared library is linked to using dlopen, instead of deferring function call resolution to the point when the function is first called.

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

llvm-svn: 249551
2015-10-07 15:00:21 +00:00
Denis Protivensky 1ef7b3ff55 [ELF2] Handle -m option
Parse and apply emulation given with -m option.
Check input files to match ELF type and machine architecture provided with -m.

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

llvm-svn: 249529
2015-10-07 09:13:03 +00:00
Denis Protivensky 92aa1c02df [ELF2] Fix gcc build error
llvm-svn: 249524
2015-10-07 08:21:34 +00:00
Rafael Espindola cea0b3b45d Don't create dynamic relocations for weak undefined symbols.
llvm-svn: 249520
2015-10-07 04:22:55 +00:00
Rafael Espindola e782f673a8 Skip entries handled by the dynamic linker.
We were writing got entries in the first positions, not in the positions
corresponding to locally defined symbols.

llvm-svn: 249518
2015-10-07 03:56:05 +00:00
Rafael Espindola c05ad3dedb Create linker generated symbols earlier.
We were incorrectly deciding that a dynamic relocation was needed for them.

llvm-svn: 249512
2015-10-07 02:51:44 +00:00
Rafael Espindola 52dca345db Create simpler dynamic relocations for local symbols in got.
If the symbol is not preemptable, we can use a R_X86_64_RELATIVE.

llvm-svn: 249496
2015-10-07 00:58:20 +00:00
Rui Ueyama ee59282bfd ELF2: Implement OUTPUT() linker script directive.
llvm-svn: 249491
2015-10-07 00:25:09 +00:00
Rafael Espindola 3378526f34 Fix typo.
llvm-svn: 249488
2015-10-07 00:15:43 +00:00
Rafael Espindola a662738e02 Don't create dynamic relocations when its known what the got points to.
llvm-svn: 249485
2015-10-06 23:56:53 +00:00
Michael J. Spencer f32446fb65 [elf2] Correctly determine if we should ignore missing __tls_get_addr.
llvm-svn: 249462
2015-10-06 20:39:09 +00:00
Davide Italiano aad4402097 [ELF2] Address r249428 post comit review. Style + test trim.
llvm-svn: 249451
2015-10-06 20:02:15 +00:00
Michael J. Spencer fcacad263a [elf2] Fix style.
llvm-svn: 249450
2015-10-06 19:57:05 +00:00