Commit Graph

58 Commits

Author SHA1 Message Date
Rafael Espindola 308363336b Move isFixupKindX86PCRel.
llvm-svn: 115545
2010-10-04 19:46:28 +00:00
Rafael Espindola baadbd554a Produce a R_X86_64_PLT32 when needed.
llvm-svn: 115541
2010-10-04 19:04:13 +00:00
Rafael Espindola b2c4ca6433 Produce a R_X86_64_GOT32 when needed.
llvm-svn: 115537
2010-10-04 18:44:25 +00:00
Rafael Espindola da0e3d07b2 Include the section address in the computation of the relocation.
llvm-svn: 115509
2010-10-04 15:59:01 +00:00
Rafael Espindola 7c48b06930 Correctly compute the relocation when it is not in the first fragment.
llvm-svn: 115506
2010-10-04 15:28:43 +00:00
Rafael Espindola f70b4e0c2e Implement a very basic PIC case.
llvm-svn: 115454
2010-10-03 00:46:57 +00:00
Rafael Espindola f987d5ea1c Factor some logic into ShouldRelocOnSymbol. This simplifies the code and
fixes some cases where we were producing relocations with at symbol that
should use a section instead.

llvm-svn: 115194
2010-09-30 20:18:35 +00:00
Rafael Espindola 70d6e0e0ff Correctly produce R_X86_64_32 or R_X86_64_32S.
With this patch in

movq    $foo, foo(%rip)
foo:
.long   foo

We produce a R_X86_64_32S for the first relocation and R_X86_64_32 for the
second one.

llvm-svn: 115134
2010-09-30 03:11:42 +00:00
Rafael Espindola 2ebaee9c75 Make it possible for the MCObjectWriter to decide if a given fixup is fully
resolved or not. Different object files have different restrictions and
different native assemblers have different idiosyncrasies we want to emulate
for now.

Move the existing MachO logic to the new place and implement an ELF one that
gets fixups to globals right.

llvm-svn: 115131
2010-09-30 02:22:20 +00:00
Rafael Espindola 01d20a76fe On elf, undefined symbols can start with .L.
llvm-svn: 114958
2010-09-28 16:19:11 +00:00
Rafael Espindola 96bfb50c03 Write relocations in the end of the file. This matches what gas does and
makes files easier to diff.

llvm-svn: 114898
2010-09-27 22:04:54 +00:00
Rafael Espindola 9735f4ff8d Factor symbol value computation into a function.
llvm-svn: 114891
2010-09-27 21:23:02 +00:00
Rafael Espindola 75d65b9a03 Move ELF to HasReliableSymbolDifference=true. Also take the opportunity to put
symbols defined in merge sections in independent atoms.

llvm-svn: 114786
2010-09-25 05:42:19 +00:00
Rafael Espindola cf1f985838 Reapply 114678 and 114667. Reverting them did not fix the bot:
http://google1.osuosl.org:8011/builders/llvm-gcc-i386-linux-selfhost/builds/69

llvm-svn: 114761
2010-09-24 21:19:03 +00:00
Rafael Espindola 3843bb9d2c Revert 114678 and 114667 to see if
http://google1.osuosl.org:8011/builders/llvm-gcc-i386-linux-selfhost

gets happy.

llvm-svn: 114742
2010-09-24 18:48:08 +00:00
Rafael Espindola f458f04eb1 Correctly handle weak undefined symbols. Before we would get a invalid binding
(2 == STB_WEAK | STB_GLOBAL).

llvm-svn: 114690
2010-09-23 19:55:14 +00:00
Rafael Espindola 6366d1b858 Correctly compute the offset of the symbol. Forgot these bits from the
last commit.

llvm-svn: 114678
2010-09-23 18:01:31 +00:00
Rafael Espindola 48e108753b Represent relocations against local symbols as relocations against the section
they are in. Both ways should be equivalent, but gas produces relocations
against the section.

Roman wrote the patch, I added the test.

llvm-svn: 114667
2010-09-23 17:25:18 +00:00
Rafael Espindola 2816588eb9 Fix the FIXME.
llvm-svn: 114639
2010-09-23 14:14:56 +00:00
Rafael Espindola 0e527b7ed5 Fix typo and add a FIXME.
llvm-svn: 114570
2010-09-22 19:04:41 +00:00
Rafael Espindola 461a692c7f Revert unrelated change that was accidentally included in the previous commit.
llvm-svn: 114383
2010-09-21 00:40:19 +00:00
Rafael Espindola f0591c1642 Implement support for .local and its "interesting" interactions with .comm.
llvm-svn: 114382
2010-09-21 00:24:38 +00:00
Rafael Espindola 32ab4558fe Produce a R_X86_64_32 when the value is >=0.
llvm-svn: 114339
2010-09-20 19:20:47 +00:00
Rafael Espindola 57e599a82a Make sure the STT_FILE symbol is the first one in the symbol table.
llvm-svn: 114285
2010-09-18 15:03:21 +00:00
Rafael Espindola 0ecde03e9f Avoid relocations in a common case.
llvm-svn: 114229
2010-09-17 22:34:41 +00:00
Rafael Espindola 44bf266111 Print the address of sections as 0 and create the metadata sections in the
same order as gnu as.

llvm-svn: 114109
2010-09-16 19:46:31 +00:00
Benjamin Kramer 6c3c349b2b MCELF: Write relocation fragments in the right endian.
- This code is gross, but does the job for now.

llvm-svn: 113509
2010-09-09 18:01:29 +00:00
Roman Divacky 3b727f55aa Make ELF OS ABI dependent on the OS from target triple.
llvm-svn: 113508
2010-09-09 17:57:50 +00:00
Roman Divacky 2ef1a589c5 ELF_STB_Local is 0 so setting and checking it must be done specially
llvm-svn: 113375
2010-09-08 18:08:40 +00:00
Roman Divacky 6c27de28b5 Unresolved weak symbols have value equal zero.
llvm-svn: 113358
2010-09-08 14:29:45 +00:00
Benjamin Kramer 3723ba1fe0 MCELF: Align symtab, relocation sections and section headers properly. Patch by Krister Wombell.
llvm-svn: 113155
2010-09-06 16:11:52 +00:00
Benjamin Kramer 4226198a1d Allow creation of SHT_NULL sections, from Roman Divacky.
llvm-svn: 112605
2010-08-31 17:03:33 +00:00
Benjamin Kramer b1b493bcab MCELF: The value of all common symbols is the offset from the start of the section. Patch by Roman Divacky.
llvm-svn: 112492
2010-08-30 17:20:17 +00:00
Benjamin Kramer 8199447851 The value is offset from the start of the section for non-common symbols, submitted by Jordan Gordeev.
llvm-svn: 112473
2010-08-30 12:00:16 +00:00
Benjamin Kramer f791b9fc56 Index external symbols by symbol table instead of parent section, by Roman Divacky.
llvm-svn: 112472
2010-08-30 11:59:29 +00:00
Chris Lattner 95bb297c26 squish dead code.
llvm-svn: 112350
2010-08-28 03:21:03 +00:00
Benjamin Kramer 05e22982c8 MCELF: Always overwrite FixedValue.
llvm-svn: 112259
2010-08-27 10:38:39 +00:00
Benjamin Kramer 2c45f431fa MCELF: Fix a thinko of mine.
llvm-svn: 112203
2010-08-26 18:12:04 +00:00
Benjamin Kramer 929cc7618f MCELF: Compensate for the addend on i386. Patch by Roman Divacky, with some cleanups.
llvm-svn: 112197
2010-08-26 17:23:02 +00:00
Benjamin Kramer 37b384cd66 MCELF: Use precomputed symbol indices, patch by Roman Divacky.
llvm-svn: 112079
2010-08-25 20:09:43 +00:00
Benjamin Kramer a536f077fe Relocate against parent if the symbol is not in section or it's a common symbol, from Roman Divacky.
llvm-svn: 111925
2010-08-24 17:34:39 +00:00
Benjamin Kramer d41b53c037 Fix thinko. Having no tests is great ...
llvm-svn: 111848
2010-08-23 21:32:00 +00:00
Benjamin Kramer c4809c930a Reduce code duplication.
llvm-svn: 111846
2010-08-23 21:23:52 +00:00
Benjamin Kramer 86511dce18 ELFObjectWriter: Run ComputeSymbolTable before recording relocations. This way we can use the information it has computed and don't have to recompute the same stuff over and over again.
llvm-svn: 111844
2010-08-23 21:19:37 +00:00
Benjamin Kramer 40f83489b4 Add the symbol offset to the relocation value when we relocate against section. By Roman Divacky.
llvm-svn: 111824
2010-08-23 19:05:46 +00:00
Benjamin Kramer 620b68e883 Use the proper relocation section + cleanup, from Roman Divacky.
llvm-svn: 111819
2010-08-23 18:24:20 +00:00
Benjamin Kramer 448886d5df MCELF: Count the section orders properly. Patch by Roman Divacky.
llvm-svn: 111517
2010-08-19 13:44:49 +00:00
Benjamin Kramer da7604f53d Remove dead code. Fixes a GCC warning.
llvm-svn: 111271
2010-08-17 19:45:05 +00:00
Benjamin Kramer 1afba421a9 Sketch i386 relocations handling, from Roman Divacky.
Hello world builds & runs now on i386/ELF with -integrated-as.

llvm-svn: 111264
2010-08-17 18:20:28 +00:00
Benjamin Kramer fd0541566b Use the correct entry size for relocation entries, from Roman Divacky.
llvm-svn: 111259
2010-08-17 17:56:13 +00:00