Commit Graph

31 Commits

Author SHA1 Message Date
Rafael Espindola 1bd885aba4 ELF: Also record the type of undefined symbols.
Tested with a weak undefined. Testing with a plain undefined will have to wait
for support for -shared.

llvm-svn: 245069
2015-08-14 16:46:28 +00:00
Rafael Espindola c44d17ad45 Add the type of the symbols to the symbol table.
For now only defined symbols are covered. I will add undefined ones in the
next patch.

llvm-svn: 245057
2015-08-14 15:10:49 +00:00
Rafael Espindola 383c323d4d ELF: Set the correct symbol binding.
llvm-svn: 245049
2015-08-14 13:52:36 +00:00
Rafael Espindola 62b81b875a Start populating the symbol table.
With this patch only the name is set. I will set the other fields shortly.

For now the table doesn't include local symbols. This is equivalent to using
--discard-all with gnu ld. This is OK for now since the symbols are not
needed for execution and for testing symbol resolution we only need the
global symbols.

llvm-svn: 245044
2015-08-14 13:07:05 +00:00
Rafael Espindola f763ca3c9c ELF: Create a symbol table.
For now it is empty. I will add the symbols in a followup patch.

llvm-svn: 245008
2015-08-14 02:42:20 +00:00
Rafael Espindola 2db634d8f1 Correctly align output sections.
They don't need to be aligned to page boundaries. Only segments need that.

llvm-svn: 244942
2015-08-13 20:24:18 +00:00
Rafael Espindola 0160a281c2 Record the alignment of the output sections.
llvm-svn: 244941
2015-08-13 20:13:39 +00:00
Rafael Espindola 64e888ba5f Set the file offset of zero sized sections.
There is no reason not to do it and this matches what gold and bfd ld do.

llvm-svn: 244929
2015-08-13 18:23:43 +00:00
Rafael Espindola a7471795ae Take name, type and flags in consideration when concatenating sections.
This is mandated by the ELF spec.

llvm-svn: 244911
2015-08-13 17:04:50 +00:00
Rafael Espindola ef1ac01c2e Don't give an address to sections that are not allocated.
llvm-svn: 244900
2015-08-13 15:31:17 +00:00
Rafael Espindola abad6186c3 Place SHF_ALLOC sections first in the output.
Having them in the middle of the file complicates the creation of segments.

llvm-svn: 244898
2015-08-13 15:23:46 +00:00
Rafael Espindola cde251370a Include non-alloca sections in the link.
llvm-svn: 244895
2015-08-13 14:45:44 +00:00
Rafael Espindola 91009b3856 Fix the alignment of the section headers.
Thanks a lot to Rui for noticing it.

llvm-svn: 244711
2015-08-12 01:45:28 +00:00
Rafael Espindola 6b83b90b6a ELF: Create a string table.
For now only the sections are in it, but it already makes the output easier
to read and test.

llvm-svn: 244702
2015-08-12 00:00:24 +00:00
Rafael Espindola 76e24ea955 Add support for weak undefined symbols.
llvm-svn: 244640
2015-08-11 17:57:05 +00:00
Rafael Espindola b13df6582a Add support for weak symbols.
llvm-svn: 244636
2015-08-11 17:33:02 +00:00
Rafael Espindola 7c388187c9 Don't report a conflict between two local symbols.
llvm-svn: 244624
2015-08-11 16:30:34 +00:00
Rafael Espindola 525d0bf0b9 On freebsd it is possible to open a directory. Test with another error.
llvm-svn: 244249
2015-08-06 19:12:03 +00:00
Rafael Espindola 08c1df6a45 Bring test back but don't check the filesytem dependent error.
llvm-svn: 244218
2015-08-06 15:18:59 +00:00
Rafael Espindola 3b8018069e For completeness, add a 64 bit big endian test.
llvm-svn: 244183
2015-08-06 00:00:50 +00:00
Rafael Espindola 1c2f64d1a6 Add a big endian testcase.
llvm-svn: 244173
2015-08-05 23:40:20 +00:00
Rafael Espindola 4b7c2fc64e Add bare minimum to get a working i386 linux program.
llvm-svn: 244050
2015-08-05 15:08:40 +00:00
Rafael Espindola d39c8cd087 Rename asm tests to .s. NFC.
llvm-svn: 244037
2015-08-05 12:14:51 +00:00
Rafael Espindola 3c9cb4b3d3 lld elf2: Diagnose trying to mix incompatible files.
This is also a step in instantiating the writer with the correct template
argument.

llvm-svn: 244035
2015-08-05 12:03:34 +00:00
Rafael Espindola 87ee8dcb64 Use ELFOSABI_NONE. This matches both bfd ld and gold.
llvm-svn: 244033
2015-08-05 11:55:52 +00:00
Rafael Espindola aefd5c1617 Create ObjectFile with the correct endian and word size.
The writer is still hard coded to 64 bits le, but with this we can test for
invalid ELF files.

llvm-svn: 243993
2015-08-04 15:45:54 +00:00
Michael J. Spencer 44fc1c0a73 [ELF2] Templatize addChunk and handle section flags.
llvm-svn: 243579
2015-07-29 22:14:50 +00:00
Michael J. Spencer 5a6f5f178e [ELF2] Emit correct section types.
llvm-svn: 243509
2015-07-29 00:52:17 +00:00
Michael J. Spencer 8039dae26d [ELF2] Emit section table.
llvm-svn: 243506
2015-07-29 00:30:10 +00:00
Michael J. Spencer c34eed3045 [ELF2] Remove broken test.
The exact error the system returns for this case is varies between OS's and file systems.

llvm-svn: 243184
2015-07-25 00:09:22 +00:00
Michael J. Spencer 84487f1174 [ELF2] Add a new ELF linker based on the new PE/COFF linker.
Differential Revision: http://reviews.llvm.org/D11188

llvm-svn: 243161
2015-07-24 21:03:07 +00:00