Commit Graph

40 Commits

Author SHA1 Message Date
Rafael Espindola 443f50a833 Create .bss only when needed.
This is a small complication, but produces nicer output and is a step to
handling zero size sections uniformly.

llvm-svn: 251980
2015-11-03 21:35:14 +00:00
Rafael Espindola d1ec682411 Update for llvm change.
llvm-svn: 251971
2015-11-03 20:02:28 +00:00
George Rimar 0f5ac9f571 [ELF2] .shstrtab section implemented
The section header table index of the entry that is associated with the section name string table.

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

llvm-svn: 250836
2015-10-20 17:21:35 +00:00
George Rimar c96c182ab4 Reverts r250775 as it breaks self-hosting.
llvm-svn: 250807
2015-10-20 08:49:43 +00:00
Davide Italiano 1ea1fd6b34 [Driver] Error out instead of silently ignoring on invalid -z argument.
This matches what both ld.bfd and gold do.

llvm-svn: 250775
2015-10-20 00:34:04 +00:00
Rui Ueyama bf3fd7c9a0 ELF2: Emit a PT_PHDR header as the first entry of the program header.
PT_PHDR entry points to the program header itself.

llvm-svn: 249839
2015-10-09 15:31:49 +00:00
Rui Ueyama 1890799f0c Re-apply r249630: ELF2: Use `-flavor gnu2` after `not` to fix Windows buildbot.
Thanks to George Rimar's r249696, `not` is now able to find ld.lld2
executable correctly.

llvm-svn: 249746
2015-10-08 20:57:29 +00:00
Rui Ueyama f82a0eef13 ELF2: Use `-flavor gnu2` after `not` to fix Windows buildbot.
`not` command on Windows is not able to find an executable from PATH
if a given command already has an extension even if the extension is
not ".exe".

llvm-svn: 249630
2015-10-07 22:20:43 +00:00
Rui Ueyama 60fe7fcc6b ELF2: Use ld.lld2 instead of lld -flavor gnu2.
llvm-svn: 249573
2015-10-07 17:31:39 +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
Rafael Espindola 98efd89e7e Use ld.lld2 as a argv[0] alias.
The reason for the name is so that we can run

./build/bin/clang -fuse-ld=lld2 test.o -o t

llvm-svn: 249122
2015-10-02 12:57:34 +00:00
Michael J. Spencer 52bf0ebfdf [lld][elf2] Sort output sections.
Sort by:
ALLOC
ALLOC && NOBITS
ALLOC & EXEC
ALLOC & EXEC && NOBITS
ALLOC & WRITE
ALLOC & WRITE && NOBITS
<nothing> (ignoring NOBITS)

The dynamic section is finalized early because it adds strings to the dynamic string table, which comes before the dynamic table.

llvm-svn: 249071
2015-10-01 21:15:02 +00:00
Rui Ueyama 819f7127c0 ELF2: Move tests for linker script from basic.s to linkerscript.s.
llvm-svn: 248961
2015-09-30 23:15:35 +00:00
Rui Ueyama bf506b7d48 ELF2: LinkerScript: Handle quoted tokens.
llvm-svn: 248919
2015-09-30 17:15:29 +00:00
Rui Ueyama f5c4aca98f ELF2: Add basic linker script support.
This linker script parser and evaluator is powerful enough to read
Linux's libc.so, which is (despite its name) a linker script that
contains OUTPUT_FORMAT, GROUP and AS_NEEDED directives.

The parser implemented in this patch is a recursive-descendent one.
It does *not* construct an AST but consumes directives in place and
sets the results to Symtab object, like what Driver is doing.
This should be very fast since less objects are allocated, and
this is also more readable.

http://reviews.llvm.org/D13232

llvm-svn: 248918
2015-09-30 17:06:09 +00:00
Rafael Espindola 6a78fd5f41 This reverts commit r248845 and r248848.
They broke elf2/basic-mips.s.

Revert "[elf2] Sort output sections."
Revert "[elf2] Fix build."

llvm-svn: 248851
2015-09-29 23:19:25 +00:00
Michael J. Spencer fe07bd67fd [elf2] Sort output sections.
Sort by:
ALLOC
ALLOC && NOBITS
ALLOC & EXEC
ALLOC & EXEC && NOBITS
ALLOC & WRITE
ALLOC & WRITE && NOBITS
<nothing> (ignoring NOBITS)

The dynamic section is finalized early because it adds strings to the dynamic string table, which comes before the dynamic table.

llvm-svn: 248845
2015-09-29 23:05:40 +00:00
Rui Ueyama a7e628ff10 ELF2: Unbreak buildbot.
Subshell didn't work on Windows.

llvm-svn: 248840
2015-09-29 22:46:52 +00:00
Rui Ueyama 4eed0114c5 ELF2: Use 'a.out' as default output file name.
llvm-svn: 248831
2015-09-29 21:49:40 +00:00
Rui Ueyama eeb22f8251 ELF2: Support reponse files.
http://reviews.llvm.org/D13148

llvm-svn: 248575
2015-09-25 15:37:33 +00:00
Rafael Espindola c2d211994d Create the .bss section early so that we don't have to set it after the fact.
llvm-svn: 248412
2015-09-23 18:25:05 +00:00
Rafael Espindola 1a49e58181 Print more information about duplicated symbols.
llvm-svn: 248380
2015-09-23 14:10:24 +00:00
Rafael Espindola 0a2e211ace Create a PT_LOAD program header for the start of the file.
With this a trivial dynamic program works with the musl dynamic linker:

LD_LIBRARY_PATH=.  ~/musl/lib/libc.so ./t

llvm-svn: 247290
2015-09-10 15:41:34 +00:00
Rafael Espindola 60252d8feb Change the load addr into something that works on linux x86_64.
With this simple static programs run again.

llvm-svn: 247205
2015-09-09 22:53:55 +00:00
Michael J. Spencer 1d299a8a9d [elf2] Assign output sections to PHDRs.
This is a minimal implementation to produce legal output. Future patches will combine multiple compatible PT_LOADs.

llvm-svn: 247185
2015-09-09 20:48:09 +00:00
Rafael Espindola 778562fc78 Add the DT_NEEDED entries to the dynamic table.
llvm-svn: 247181
2015-09-09 20:26:23 +00:00
Rafael Espindola 3f4228f613 Start adding content to the dynamic section.
With this patch we create a dynamic string table (it is allocated, unlike
the regular one) and the dynamic section has a DT_STRTAB pointing to it.

llvm-svn: 247155
2015-09-09 15:33:08 +00:00
Michael J. Spencer 546c64c733 [lld][elf2] Fix hard coded entry address.
llvm-svn: 247089
2015-09-08 22:34:57 +00:00
Rafael Espindola b9fe03d4a9 Revert "[lld][elf2] Fix hard coded entry address."
This reverts commit r247073.

It broke

    lld :: elf2/basic32be.s
    lld :: elf2/basic64be.s

llvm-svn: 247077
2015-09-08 21:32:44 +00:00
Michael J. Spencer 8be15899b4 [lld][elf2] Fix hard coded entry address.
llvm-svn: 247073
2015-09-08 21:11:25 +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 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 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 d39c8cd087 Rename asm tests to .s. NFC.
llvm-svn: 244037
2015-08-05 12:14:51 +00:00