Commit Graph

1408 Commits

Author SHA1 Message Date
Shankar Easwaran 9691b01905 [ELF] Rename File.h to ELFFile.h to avoid confusion.
No change in functionality.

llvm-svn: 200166
2014-01-26 23:49:07 +00:00
Shankar Easwaran b888433e9c [ELF] Dont include all targets
llvm-svn: 200165
2014-01-26 23:47:18 +00:00
Rui Ueyama 56c4611340 [PECOFF] Emit PE32+ file header.
llvm-svn: 200128
2014-01-26 05:34:12 +00:00
Rui Ueyama c6ddf5654c [PECOFF] Use a shorter name for the parameter.
llvm-svn: 200107
2014-01-26 00:37:30 +00:00
Rui Ueyama 76c1b4d0fb [PECOFF] Set PE32+ magic value if 64 bit.
llvm-svn: 200106
2014-01-26 00:35:23 +00:00
Rui Ueyama 7dc69287c1 [PECOFF] Use a shorter name for the PECOFF writer member.
llvm-svn: 200052
2014-01-25 00:27:44 +00:00
Rui Ueyama 49bfd5032d [PECOFF] Accept /machine:x64 option.
This is the first patch to support PE32+ format, which is the image format
to use 64 bit address space on Windows/x86-64.

llvm-svn: 200029
2014-01-24 19:17:05 +00:00
Rui Ueyama 87e15c7585 [PECOFF] Use constant instead of magic number.
llvm-svn: 200019
2014-01-24 18:03:14 +00:00
Simon Atanasyan d8cadd6f17 [ELF] Customize a relocation table output format (rel / rela).
Add new virtual virtual function `isRelaOutputFormat` to the
`ELFLinkingContext` class. Call this function everywhere we need to
select a relocation table format.

Patch reviewed by Shankar Easwaran and Rui Ueyama.

llvm-svn: 199973
2014-01-24 05:21:21 +00:00
Rafael Espindola 6ba68f10c4 Update for llvm api change.
llvm-svn: 199777
2014-01-22 00:14:56 +00:00
Rafael Espindola 79e2d936fd Update for llvm api change.
llvm-svn: 199752
2014-01-21 16:09:55 +00:00
Simon Atanasyan eafb76ee9b [Mips] Specify the type of a symbol table entries in the test assembler
file.

llvm-svn: 199561
2014-01-18 21:13:05 +00:00
Simon Atanasyan 9dec22dbe2 [Mips] Use explicit assembler instructions in the tests.
llvm-svn: 199556
2014-01-18 16:59:19 +00:00
Simon Atanasyan 2f1d6366e7 [Mips] Emit ELF header for MIPS target. ELF flags set is mostly hardcoded.
Later we need to improve that solution and build a correct set of flags
by merging ELF flags from all input objects.

llvm-svn: 199555
2014-01-18 16:59:11 +00:00
Simon Atanasyan 0e57a77072 [Mips] Simplify calculations of relocations - replace scatterBits calls
by bitwise AND operator and remove redundant local variables.

llvm-svn: 199554
2014-01-18 16:59:00 +00:00
Rui Ueyama 8d7a6f2898 Fix odd titlecasing and spacing in an error message.
llvm-svn: 199530
2014-01-18 00:57:40 +00:00
Rui Ueyama 251e68b6ae Use auto for readability. No functionality change.
llvm-svn: 199527
2014-01-18 00:38:44 +00:00
Rui Ueyama d9696cbda8 Using "final" as a variable name is a bit confusing in C++11, so rename it.
llvm-svn: 199526
2014-01-18 00:27:03 +00:00
Simon Atanasyan 9ab3b8db84 [Mips] Allocate local GOT entry for a global symbol defined in an
executable file.

llvm-svn: 199517
2014-01-17 21:18:45 +00:00
Simon Atanasyan 362bdc125e [Mips] Implement .plt and .got.plt section creation.
llvm-svn: 199516
2014-01-17 21:18:37 +00:00
Simon Atanasyan 66338224be [Mips] Handle R_MIPS_26 relocation. Maintaining of .plt and .got.plt
sections will be implemented later.

llvm-svn: 199515
2014-01-17 21:18:26 +00:00
Simon Atanasyan 80b86a43d5 [Mips] Provide default name of MIPS-specific interpreter.
llvm-svn: 199514
2014-01-17 21:18:14 +00:00
Rui Ueyama acc795383b [PECOFF] Tests for DLL name in the export table.
llvm-svn: 199428
2014-01-16 21:31:27 +00:00
Rui Ueyama 1792ebc1ab Relax the expected output so that the tests become robust against llvm-objdump format change.
llvm-svn: 199421
2014-01-16 20:41:16 +00:00
Rui Ueyama 2b75630b3b [PECOFF] Make export table tests readable.
llvm-svn: 199409
2014-01-16 18:57:22 +00:00
Rafael Espindola 0de92d53a1 Update for llvm api change.
llvm-svn: 199327
2014-01-15 19:38:01 +00:00
Rui Ueyama 4dcc4637b5 [CMake] Add llvm-mc to the list of test dependencies.
llvm-svn: 199274
2014-01-14 23:33:04 +00:00
Joey Gouly 010b37691d [MachO] Begin support for reading fat binaries.
llvm-svn: 199259
2014-01-14 22:32:38 +00:00
Simon Atanasyan 13c5ce53dc [Mips] Do not forget to initialize a class field.
llvm-svn: 199241
2014-01-14 18:20:07 +00:00
Simon Atanasyan e46e2dfe01 [Mips] Calculate gp value only once.
llvm-svn: 199240
2014-01-14 18:20:00 +00:00
Simon Atanasyan db2e1f35d8 [Mips] Create and initialize _gp symbol.
llvm-svn: 199239
2014-01-14 18:19:52 +00:00
Simon Atanasyan 3b1a761374 [Mips] Check initialization of _gp_disp and _GLOBAL_OFFSET_TABLE_
symbols in case of executable file linking.

llvm-svn: 199238
2014-01-14 18:19:42 +00:00
Simon Atanasyan 6cac582de5 [Mips] Do not store a pointer to the AtomLayout related to the
_GLOBAL_OFFSET_TABLE_ symbol. We do not use this ponter anywhere after
assigning of virtual address.

llvm-svn: 199237
2014-01-14 18:19:35 +00:00
Simon Atanasyan 0b4dd91582 [Mips] Factor out constant represents gp value offset to the
MipsTargetLayout class method.

llvm-svn: 199236
2014-01-14 18:19:26 +00:00
Simon Atanasyan acb301fab1 [Mips] Set default executable entry symbol name for MIPS targets. On
MIPS the entry symbol name is '__start' instead of '_start'.

llvm-svn: 199235
2014-01-14 18:19:19 +00:00
Simon Atanasyan 663aa62863 [Mips] Set default base address for MIPS executables to 0x400000. Assign
the lowest segment address to the MIPS_BASE_ADDRESS dynamic tag.

llvm-svn: 199234
2014-01-14 18:19:12 +00:00
Simon Atanasyan a565c778b3 [ELF] Fix type of the DefaultLayout::segments() return value. This
method returns the DefaultLayout::_segments field. The type of this field is
a vector of Segment<ELFT>* pointers. This type cannot be implicitly casted to
the range<ChunkIter>.

llvm-svn: 199233
2014-01-14 18:19:02 +00:00
Simon Atanasyan a0f5caac26 [Mips] Add test case to check R_MIPS_HI16 / R_MIPS_LO16 relocations
agains _gp_disp symbol.

llvm-svn: 199232
2014-01-14 18:18:56 +00:00
Simon Atanasyan 2a1ae098b3 [Mips] Move got16.test assembler source code to the test file and use
llvm-mc for an object file generation.

llvm-svn: 199231
2014-01-14 18:18:49 +00:00
Rui Ueyama ab9deb5466 [PECOFF] Support STACKSIZE module-definition file directive.
llvm-svn: 199170
2014-01-14 00:48:25 +00:00
Rui Ueyama ca9e99fe50 Add a function to verify an ExportDesc.
llvm-svn: 199167
2014-01-14 00:29:26 +00:00
Rui Ueyama 37f5273773 Do not use "auto" where actual type is obvious and short.
llvm-svn: 199166
2014-01-14 00:06:50 +00:00
Rui Ueyama 1c1487494d Reduce even more boilerplate.
llvm-svn: 199165
2014-01-13 23:54:49 +00:00
Rui Ueyama 7c13c4459b Whitespace.
llvm-svn: 199164
2014-01-13 23:21:33 +00:00
Rui Ueyama 1090434d39 Reduce the boilerplate in the test cases for the module-definition file.
llvm-svn: 199163
2014-01-13 23:13:21 +00:00
Rui Ueyama cbc6eb3e99 Use bettter names for the tests.
llvm-svn: 199161
2014-01-13 23:02:03 +00:00
Rui Ueyama 69c26e903b [PECOFF] Add another test for the module-definition file parser.
llvm-svn: 199159
2014-01-13 22:55:09 +00:00
Rui Ueyama 0c306ba08c Add comment to bit manipulation functions.
llvm-svn: 199156
2014-01-13 22:29:16 +00:00
Joey Gouly d2215375a8 [MachO] Add basic support for local symbols.
llvm-svn: 199155
2014-01-13 22:28:02 +00:00
Nick Kledzik 0052bd4a34 Fix spacing
llvm-svn: 199074
2014-01-13 04:08:15 +00:00
Joey Gouly 9c826c100a Factor the symbol handling in normalizedToAtoms into a separate function.
No functionality change.

llvm-svn: 199066
2014-01-12 22:55:49 +00:00
Rui Ueyama 415625028c [PECOFF] Support VERSION directive.
llvm-svn: 199022
2014-01-11 22:45:00 +00:00
Rui Ueyama 605f7791a3 Make anonymous namespace as small as possible.
llvm-svn: 199021
2014-01-11 22:15:54 +00:00
Rui Ueyama b214e1aba2 [PECOFF] Support NAME directive.
llvm-svn: 199020
2014-01-11 21:53:46 +00:00
Rui Ueyama 66a4445658 [PECOFF] Add a helper function to read an integer from .def file.
llvm-svn: 199019
2014-01-11 21:37:25 +00:00
Rui Ueyama 6cc96bf2d2 [PECOFF] Print a better error message for unknown module-definition file directive.
llvm-svn: 199018
2014-01-11 21:24:43 +00:00
Rui Ueyama 6a5f7c22ad [PECOFF] Support HEAPSIZE directive.
llvm-svn: 198994
2014-01-11 01:58:21 +00:00
Rui Ueyama f98a18acb7 [PECOFF] Refactor module-defintion file parser.
Refactor the parser so that the parser can return arbitrary type of parse
result other than a vector of ExportDesc. Parsers for non-EXPORTS directives
will be implemented in different patches. No functionality change.

llvm-svn: 198993
2014-01-11 01:33:42 +00:00
Nick Kledzik 8293c711e7 [yaml] use BumpPtrAllocator for string copies
llvm-svn: 198987
2014-01-11 01:11:49 +00:00
Nick Kledzik 6edd722a2c [mach-o] enable mach-o and native yaml to be intermixed
The main goal of this patch is to allow "mach-o encoded as yaml" and "native
encoded as yaml" documents to be intermixed.  They are distinguished via 
yaml tags at the start of the document.  This will enable all mach-o test cases
to be written using yaml instead of checking in object files.

The Registry was extend to allow yaml tag handlers to be registered.  The
mach-o Reader adds a yaml tag handler for the tag "!mach-o". 

Additionally, this patch fixes some buffer ownership issues.  When parsing
mach-o binaries, the mach-o atoms can have pointers back into the memory 
mapped .o file.  But with yaml encoded mach-o, name and content are ephemeral, 
so a copyRefs parameter was added to cause the mach-o atoms to make their
own copy.  

llvm-svn: 198986
2014-01-11 01:07:43 +00:00
Rui Ueyama b8912b4f28 [PECOFF] Add a unit test for r198925.
llvm-svn: 198974
2014-01-10 23:29:12 +00:00
Rui Ueyama 8b14d14209 [PECOFF] Support module-definition file.
Module-definition (.def) files are the file containing linker directives,
such as export symbols. Because link.exe supports the same features as command
line options, just as some Linker Script commands overlaps with command line
options, use of module-definition file is not really necessary. It provides
an alternative way to specify some linker options.

This patch implements EXPORTS directive. Other directives will be implemented
in the future.

llvm-svn: 198925
2014-01-10 10:19:47 +00:00
Simon Atanasyan c955a0cfd3 [Mips] Reduce the number of type-casting calls.
llvm-svn: 198855
2014-01-09 07:52:31 +00:00
Rui Ueyama 752abd556e Add a blank line to FileCheck input.
FileCheck does not like the empty input file, so adding a blank line to workaround.

llvm-svn: 198839
2014-01-09 02:47:52 +00:00
Rui Ueyama 51a6b87ca3 Write temporary files to Output directory.
llvm-svn: 198829
2014-01-09 01:11:51 +00:00
Rui Ueyama 76d2fa70be [PECOFF] Add a test for r197803.
llvm-svn: 198828
2014-01-09 01:11:48 +00:00
Rui Ueyama c15e1b087b Add missing triples so that these tests pass on 32 bit arch.
llvm-svn: 198812
2014-01-09 00:07:20 +00:00
Simon Atanasyan 7f82bc590d [Mips] Remove unnecessary #include pragma.
llvm-svn: 198798
2014-01-08 22:00:35 +00:00
Rafael Espindola d28918b289 Use getError instead of the error_code operator.
llvm-svn: 198797
2014-01-08 22:00:09 +00:00
Simon Atanasyan 073c2d2974 [Mips] GOT16 relocation against non-local symbol does not require a
paired LO16 relocation.

llvm-svn: 198790
2014-01-08 20:43:03 +00:00
Simon Atanasyan 05c88f9b61 [Mips] Add assert to check that we handle all paired relocations.
llvm-svn: 198789
2014-01-08 20:42:52 +00:00
Simon Atanasyan 2ab9f28977 [Mips] Factor out the code determines type of GOT entry (local/global)
into the separate function.

llvm-svn: 198788
2014-01-08 20:42:45 +00:00
Simon Atanasyan 50cf77bc2f [Mips] Do not use standard relocation identifier R_MIPS_NONE for
internal purpose. Use special LLD_R_MIPS_GLOBAL_GOT constant for that.

llvm-svn: 198787
2014-01-08 20:42:38 +00:00
Simon Atanasyan fc2e4e6a76 [Mips] Rename function to better reflect its purpose.
llvm-svn: 198786
2014-01-08 20:42:30 +00:00
Simon Atanasyan eef5351416 [Mips] Do not save GOT headers atoms into the RelocationPass class
fields.

llvm-svn: 198785
2014-01-08 20:42:23 +00:00
Simon Atanasyan 30464f0293 [Mips] Rename some classes to skip redundant mentioning of 'mips'.
llvm-svn: 198784
2014-01-08 20:42:17 +00:00
Simon Atanasyan 6e0232ce59 [Mips] Move MipsGOTPass implementation to the separate file.
llvm-svn: 198783
2014-01-08 20:42:11 +00:00
Nick Kledzik 36baa33fc1 [mach-o] properly extract atom content from subrange of section content
llvm-svn: 198728
2014-01-08 02:52:58 +00:00
Nick Kledzik 360a1434f0 Use the mach-o MH_* name for file types in yaml
llvm-svn: 198725
2014-01-08 01:38:07 +00:00
Rui Ueyama 903b14432d Remove leading underscore from parameters.
llvm-svn: 198642
2014-01-06 22:43:31 +00:00
Rui Ueyama b5531d7edb Rename parameters to fix shadow warnings.
llvm-svn: 198641
2014-01-06 22:31:01 +00:00
Rui Ueyama 54174c6f16 [PECOFF] Simplify: Replace two-value enum with bool.
llvm-svn: 198634
2014-01-06 19:55:58 +00:00
Rui Ueyama 14133d5551 Replace nested switch statements.
Differential Revision: http://llvm-reviews.chandlerc.com/D2501

llvm-svn: 198535
2014-01-05 02:41:07 +00:00
Joey Gouly 41cb030b53 [MachO] Add some missing NListTypes.
llvm-svn: 198468
2014-01-04 01:22:05 +00:00
Joey Gouly ceb16dedef [MachO] Begin to add some MachO specific File/Atoms, and add the start of
normalizedToAtoms.

llvm-svn: 198459
2014-01-03 23:12:02 +00:00
Joerg Sonnenberger 03ed4cf0a4 Typo
llvm-svn: 198434
2014-01-03 18:43:32 +00:00
Rui Ueyama 76bc5157c2 Use scoped enum.
llvm-svn: 198396
2014-01-03 03:29:15 +00:00
Joerg Sonnenberger 1e259e79b9 No else after return.
llvm-svn: 198339
2014-01-02 19:30:56 +00:00
Joerg Sonnenberger 4dcee6960f Add default search path if -nostdlib is not provided.
Add basic emulation mapping for NetBSD/amd64, so that clang -m32 works
as expected.

llvm-svn: 198337
2014-01-02 19:18:36 +00:00
Joey Gouly 600bfa42ec Remove extra semicolon.
llvm-svn: 198275
2014-01-01 10:07:45 +00:00
NAKAMURA Takumi d40d387fb1 Update the copyright credits -- Happy new year 2014!
FIXME: Dragonegg may be updated at non-trivial changes.
llvm-svn: 198274
2014-01-01 08:27:31 +00:00
Joey Gouly 0518453e2e The return value of createInternalFiles is unused, so remove it.
llvm-svn: 198266
2013-12-31 19:15:42 +00:00
Rui Ueyama 93f760468e Simplify if ... return repetition.
llvm-svn: 198108
2013-12-28 10:09:21 +00:00
Rui Ueyama ffd810525d [PECOFF] Warn only when /export options are not compatible.
Currently LLD always print a warning message if the same symbol is specified
more than once for /export option. It's a bit annoying because specifying the
same symbol with compatible options is actually safe and considered as a
normal use case. This patch makes LLD to warn only when incompatible export
options are given.

llvm-svn: 198104
2013-12-28 08:40:37 +00:00
Rui Ueyama 02dfdbcbd6 temporary commit
llvm-svn: 198103
2013-12-28 08:40:23 +00:00
Rui Ueyama ad79838aa8 [PECOFF] Use std::set to store export symbol descriptors.
Each export symbol descriptor has unique name attribute, so std::set is
better container than std::vector for it. No functionality change.

llvm-svn: 198102
2013-12-28 08:11:21 +00:00
Joey Gouly 53c99b78a8 Fix a gcc-4.8 warning, about extraneous semicolons.
llvm-svn: 198091
2013-12-28 00:46:57 +00:00
Rui Ueyama ce9b9abb15 [PECOFF] Add file extensions to temporary files.
No functionality change.

llvm-svn: 198075
2013-12-27 08:37:40 +00:00
Rui Ueyama c96b41c375 [PECOFF] Add a test for /noentry.
llvm-svn: 198074
2013-12-27 08:19:21 +00:00
Rui Ueyama e6ed0f255f [PECOFF] Change the DLL entry symbol.
I'm not 100% sure but it looks like DLL entry symbol (DLL initializer function
name) should be _DllMainCRTStartup@12. The reason why I'm not very sure is
because I have no idea what "@12" suffix is, but without it the symbol won't
be resolved...

llvm-svn: 198072
2013-12-27 07:14:34 +00:00