Commit Graph

322 Commits

Author SHA1 Message Date
Nick Kledzik e34182f396 [mach-o] binary reader and writer
This patch adds support for converting normalized mach-o to and from binary
mach-o. It also changes WriterMachO (which previously directly wrote a 
mach-o binary given a set of Atoms) to instead do it in two steps. The first 
step uses normalizedFromAtoms() to convert Atoms to normalized mach-o, and the
second step uses writeBinary() which to generate the mach-o binary file.  

llvm-svn: 194167
2013-11-06 21:36:55 +00:00
Rui Ueyama 7e77a294dc [PECOFF] Report error if there's unknown flag in .drectve
Errors in .drectve section were silently ignored. This patch fixes the issue.

llvm-svn: 194110
2013-11-05 23:53:15 +00:00
Rui Ueyama 5efbc6379e [PECOFF] Fix the test to run.
llvm-svn: 194003
2013-11-04 19:01:57 +00:00
Rui Ueyama f23b27a837 [PECOFF] Add a test for the resource file.
llvm-svn: 193982
2013-11-04 05:17:54 +00:00
Rui Ueyama 2c717faa19 [ELF] Allow colons in the path.
This patch should fix the test when it runs on Windows, by allowing drive
letter separator (colon) in the path. Now all LLD ELF tests passed on MSVC
2012 32-bit. Hooray!

llvm-svn: 193978
2013-11-04 04:30:37 +00:00
Rui Ueyama 0a5802a260 [ELF] Add missing -target option.
llvm-svn: 193974
2013-11-04 03:08:55 +00:00
Rafael Espindola 3c4739cc11 Update test now that llvm-nm prints the correct value.
llvm-svn: 193913
2013-11-02 05:21:29 +00:00
Rui Ueyama 329211bbb7 [ELF] One more file for missing -target option.
llvm-svn: 193911
2013-11-02 03:55:51 +00:00
Rui Ueyama 2ccdfb219d [ELF] Add missing -target options.
These tests assume that the created objects are for x86_64. These tests
failed on non-x86_64 environments, such as 32 bit Windows.

llvm-svn: 193910
2013-11-02 03:50:03 +00:00
Rui Ueyama e4aaa335dd Single-quotes to quote parentheses.
On Windows, neither "(" nor ")" are shell special characters, so -\( is passed
as-is to LLD. Because of that this test was failing on Windows.

llvm-svn: 193905
2013-11-02 02:07:37 +00:00
Rui Ueyama 9625b5435b Fix test on 32 bit.
This patch adds "-target x86_64" to the command line. Without this option,
a 32 bit object file would be created on 32 bit machine, resulting in test
failure.

llvm-svn: 193904
2013-11-02 01:55:42 +00:00
Michael J. Spencer 5fbce5bd56 [ELF] Implement minimal support for .eh_frame_hdr.
llvm-svn: 193662
2013-10-30 00:02:04 +00:00
Shankar Easwaran 51bfb820cc [test] Fix a test failure, this test is only applicable in debug mode
llvm-svn: 193586
2013-10-29 05:26:49 +00:00
Shankar Easwaran 2bc24928d3 [PassManager] add ReaderWriter{Native,YAML} to the Driver.
Enable this for the following flavors

a) core
b) gnu
c) darwin

Its disabled for the flavor PECOFF. Convenient markers are added with FIXME
comments in the Driver that would be removed and code removed from each flavor.

llvm-svn: 193585
2013-10-29 05:12:14 +00:00
Rui Ueyama 90173df289 [PECOFF] Fix __ImageBase symbol.
__ImageBase is an absolute symbol whose address is the same as the image base
address. What we did before this patch was to create __ImageBase symbol as a
symbol whose *contents* (not location) is the image base address, which is
clearly wrong.

llvm-svn: 193565
2013-10-29 00:33:34 +00:00
Shankar Easwaran fe0b80b321 [ELF][test] Remove default section names for known contentTypes.
llvm-svn: 193483
2013-10-26 19:38:42 +00:00
Shankar Easwaran b0022c00a3 [X86_64] Fix the atom that need to be exported.
llvm-svn: 193481
2013-10-26 19:38:37 +00:00
Michael J. Spencer 707f591fa0 [ELF] Implement .{init,fini}_array ordering.
llvm-svn: 193451
2013-10-25 23:59:06 +00:00
Rui Ueyama 0145c56306 [PECOFF] Handle edge case where no section alignment is specified.
llvm-svn: 193385
2013-10-25 00:54:13 +00:00
Michael J. Spencer 28c7a21b29 [ELF] Refactor x86-64 relocation pass.
This renames the GOTPLTPass to RelocationPass and refactors it to better
represent the different types of relocations.

llvm-svn: 193379
2013-10-24 22:46:48 +00:00
Rui Ueyama 5d32d96f91 [PECOFF] Fix spelling in manifest XML.
llvm-svn: 193375
2013-10-24 22:08:19 +00:00
Michael J. Spencer 2fd6c7d91c [ELF][x86-64] Generate PLT for R_*_32S relocs.
llvm-svn: 193369
2013-10-24 21:00:25 +00:00
Rui Ueyama 671c8013ed Revert "r193300 - [PassManager] add ReaderWriter{Native, YAML} to the Driver"
The patch have completely broken COFF port and disabled many tests.
This also reverts r193302 (comment fix).

llvm-svn: 193362
2013-10-24 18:22:16 +00:00
Shankar Easwaran 89c2d8faca [PassManager] add ReaderWriter{Native,YAML} to the Driver.
Disable tests to be run with REQUIRES: disable. Note disable is not added to the
config by the test runner Mkaefiles, so essentially disables the test.

Code changes would be required to fix these tests :-

test/darwin/hello-world.objtxt
test/elf/check.test
test/elf/phdr.test
test/elf/ppc.test
test/elf/undef-from-main-dso.test
test/elf/X86_64/note-sections-ro_plus_rw.test
test/pecoff/alignment.test
test/pecoff/base-reloc.test
test/pecoff/bss-section.test
test/pecoff/drectve.test
test/pecoff/dynamic.test
test/pecoff/dynamicbase.test
test/pecoff/entry.test
test/pecoff/hello.test
test/pecoff/imagebase.test
test/pecoff/importlib.test
test/pecoff/lib.test
test/pecoff/multi.test
test/pecoff/reloc.test
test/pecoff/weak-external.test

llvm-svn: 193300
2013-10-24 03:30:03 +00:00
Rui Ueyama 99d7013ef2 Run layout-transitivity test only when debugging is enabled.
Because it depends on "-mllvm -debug" flag, the test fails in Release build.

llvm-svn: 193271
2013-10-23 21:15:48 +00:00
Rui Ueyama c05fa0beab Disable layout-transitivity test on FreeBSD for now.
llvm-svn: 193259
2013-10-23 18:22:26 +00:00
Rui Ueyama af589f70d0 [PECOFF] Emit the side-by-side manifest file.
llvm-svn: 193207
2013-10-22 22:58:07 +00:00
Rui Ueyama 53e77efac3 Disable layout-transitivity test on Darwin for now.
llvm-svn: 193121
2013-10-21 22:19:27 +00:00
Rui Ueyama 46bf8286db Fix bug that CompareAtoms::compare is not transitive.
This patch fixes a bug in r190608. The results of a comparison function
passed to std::sort must be transitive, which is, if a < b and b < c, and if
a != b, a < c must be also true. CompareAtoms::compare did not actually
guarantee the transitivity. As a result the sort results were sometimes just
wrong.

Consider there are three atoms, X, Y, and Z, whose file ordinals are 1, 2, 3,
respectively. Z has a property "layout-after X". In this case, all the
following conditionals become true:

  X < Y because X's ordinal is less than Y's
  Y < Z because Y's ordinal is less than Z's
  Z < X because of the layout-after relationship

This is not of course transitive. The reason why this happened is because
we used follow-on relationships for comparison if two atoms falls in the same
follow-on chain, but we used each atom's properties if they did not. This patch
fixes the issue by using follow-on root atoms for comparison to get consistent
results.

Differential Revision: http://llvm-reviews.chandlerc.com/D1980

llvm-svn: 193029
2013-10-19 03:18:18 +00:00
Rui Ueyama 1ce8a0a8ed [PECOFF] Only COMDAT symbols are allowed to be dead-stripped.
We should dead-strip atoms only if they are created for COMDAT symbols. If we
remove non-COMDAT atoms from a binary, it will no longer be guaranteed that
the binary will work correctly.

In COFF, you can manipulate the order of section contents in the resulting
binary by section name. For example, if you have four sections
.data$unique_prefix_{a,b,c,d}, it's guaranteed that the contents of A, B, C,
and D will be consecutive in the resulting .data section in that order.
Thus, you can access B's and C's contents by incrementing a pointer pointing
to A until it reached to D. That's why we cannot dead-strip B or C even if
no one is directly referencing to them.

Some object files in the standard library actually use that technique.

llvm-svn: 193017
2013-10-18 23:54:55 +00:00
Shankar Easwaran b6c825a5cf [ELF] Set ordinals properly to all atoms.
llvm-svn: 192939
2013-10-18 02:12:17 +00:00
Rui Ueyama f3630fe4be Make undefines check into an assertion.
Dead-strip root symbols can be undefined atoms, but should not really be
nonexistent, because dead-strip root symbols should be added to initial
undefined atoms at startup. Whenever you look up its name in the symbol
table, some type of atom will always exist.

llvm-svn: 192831
2013-10-16 19:21:50 +00:00
Rui Ueyama 2847831771 Propagate deadStripOptimize()'s failure to the caller.
We want to make the program to exit with non-zero exit code if there's an error
during dead stripping.

llvm-svn: 192771
2013-10-16 05:03:39 +00:00
Shankar Easwaran 11202deb4a [ELF] Add alias options for start-group/end-group options.
There are aliases for --start-group/--end-group options represented
by -( and -) respectively in the command line.

This change adds and improves the test for the alias options to be
tested.

Looks like users use this option widely than explicitly using
--start-group/--end-group.

llvm-svn: 192470
2013-10-11 17:59:47 +00:00
Shankar Easwaran bcf36560fd [ELF] Fix Atoms in the same file had overlapping ordinals.
This also reverts the LayoutPass to use std::sort as all files
have an ordinal now.

llvm-svn: 192409
2013-10-11 01:50:04 +00:00
Shankar Easwaran 5d859e05f2 [test] Ignore failure for now for Darwin.
This is only a step to clean the buildbot.

llvm-svn: 192368
2013-10-10 17:12:50 +00:00
Shankar Easwaran c5ed819b02 [ELF] Return error from invalid linker script parse.
llvm-svn: 192360
2013-10-10 16:59:53 +00:00
Rui Ueyama 9f3a77a9f4 [PECOFF] Add files appear in .drectve to input graph
-- so that command line options to specify new input files, such as
/defaultlib:foo, is handled properly. Such options were ignored before
this patch.

llvm-svn: 192342
2013-10-10 05:39:43 +00:00
Shankar Easwaran 95d4e61411 [ELF] Change MaxAlignment to 2.
llvm-svn: 192310
2013-10-09 18:12:31 +00:00
Shankar Easwaran 091a18070b [test] Just use the exit code from the test for now.
Will fix this in later commits. Not sure why the regex is not passing.

llvm-svn: 192273
2013-10-09 04:30:17 +00:00
Shankar Easwaran 127d04a440 [test] Fix regex for failing test on bot
llvm-svn: 192270
2013-10-09 03:53:32 +00:00
Shankar Easwaran 03f7763d21 [inputGraph] Associate Resolve state with appropriate nodes
This associates resolveState to FileNodes. The control node derive
their resolution state from the inputElements that are contained in
it.

This makes --start-group/--end-group to work with ELF linking.

llvm-svn: 192269
2013-10-09 03:40:29 +00:00
Shankar Easwaran a96f3a3da4 [lld][InputGraph] Change the Resolver to use inputGraph
Changes :-

a) Functionality in InputGraph to insert Input elements at any position
b) Functionality in the Resolver to use nextFile
c) Move the functionality of assigning file ordinals to InputGraph
d) Changes all inputs to MemoryBuffers
e) Remove LinkerInput, InputFiles, ReaderArchive

llvm-svn: 192081
2013-10-07 02:47:09 +00:00
Michael J. Spencer d419dbcc48 [ELF] Fix uninitalized value.
llvm-svn: 191924
2013-10-03 19:25:34 +00:00
Michael J. Spencer c80f88a94e [Core] Fix heap overflow in LayoutPass.
Found this with asan. Code assumes that find doesn't return end, thus if
both atoms didn't have followon roots it would still compare their positions.

llvm-svn: 191865
2013-10-02 23:21:07 +00:00
Rui Ueyama 053d9313f2 Re-submit [PECOFF] Add a test for the import table.
llvm-svn: 191580
2013-09-27 22:48:06 +00:00
Michael J. Spencer 102f82a74e [ELF] Handle copy relocations for PC32.
This will eventually need to be refactored to better handle COPY relocations,
as other relocations can also generate them. I'm not yet sure the exact
circumstances in which they are needed yet.

llvm-svn: 191567
2013-09-27 21:30:27 +00:00
Michael J. Spencer 3b36473007 [ELF] Mark STT_GNU_IFUNC symbols as code.
llvm-svn: 191566
2013-09-27 21:30:04 +00:00
Rui Ueyama a7ec3898d6 Revert "[PECOFF] Add a test for the import table."
This reverts r191469 because the original patch this one depends on (r191472)
was reverted.

llvm-svn: 191479
2013-09-27 01:26:53 +00:00
Rui Ueyama 9eb1432a99 [PECOFF] Add a test for the import table.
llvm-svn: 191475
2013-09-27 00:56:37 +00:00