Commit Graph

133 Commits

Author SHA1 Message Date
Jason W Kim 16b75262c4 Make the <ARCH>ELFObjectWriter statics private
llvm-svn: 119982
2010-11-22 18:57:00 +00:00
Jason W Kim 84ffdd5cf1 Fix misplaced statics.
llvm-svn: 119981
2010-11-22 18:47:05 +00:00
Jason W Kim a262546df7 Kill trailing whitespace
llvm-svn: 119979
2010-11-22 18:42:07 +00:00
Jason W Kim 7c7d0ef287 Refactor the ELFRelocationEntry (pull up) and move the arch-specific statics to inside the class where it belongs.
Next step is to rationally break apart the RecordRelocation()

Probably the step will be to have 1 member function for ech slot of the ELFRelocationEntry()

llvm-svn: 119978
2010-11-22 18:41:13 +00:00
Wesley Peck 7699d6cfe9 Implement ELF object file writing support for the MBlaze backend. Its not perfect yet, but it works for many tests.
llvm-svn: 119952
2010-11-21 22:06:28 +00:00
Rafael Espindola 26cb15a549 Handle PCRel relocations with absolute values. Fixes PR8656.
llvm-svn: 119917
2010-11-21 00:48:25 +00:00
Rafael Espindola 7d19efd6ff A bit more of gnu as compatibility when handling relocations with aliases.
llvm-svn: 119328
2010-11-16 04:11:46 +00:00
Benjamin Kramer 202d91e433 Fix compiler warnigns.
llvm-svn: 119175
2010-11-15 19:20:50 +00:00
Rafael Espindola 8c3039b67b Change MCExpr::EvaluateAsRelocatableImpl of variables to return the original
variable if recursing fails to simplify it.

Factor AliasedSymbol to be a method of MCSymbol.

Update MCAssembler::EvaluateFixup to match the change in
EvaluateAsRelocatableImpl.

Remove the WeakRefExpr hack, as the object writer now sees the weakref with
no extra effort needed.

Nothing else is using MCTargetExpr, but keep it for now.

Now that the ELF writer sees relocations with aliases, handle

    .weak    foo2
foo2:
    .weak    bar2
    .set    bar2,foo2
    .quad    bar2

the same way gas does and produce a relocation with bar2.

llvm-svn: 119152
2010-11-15 16:33:49 +00:00
Jason W Kim 96f4c01cb3 Dovetail with Dan Dunbar's rework of ELFObjectWriter.
Added 2 new subclasses - X86ELFObjectWriter and ARMELFObectWriter.
ARM and X86 require different code for RecordRelocation(), possibly others.

llvm-svn: 119149
2010-11-15 16:18:39 +00:00
Rafael Espindola 240028d11d Move the logic to decide with which symbol we produce a relocation (if any) to
a central location. This also makes us a bit more compatible with gas.

llvm-svn: 119094
2010-11-14 23:53:26 +00:00
Rafael Espindola 7d0ba3464e Handle a peculiar comdat case: Creating a section with an undefined
signature symbol causes a local symbol to be created unless there is
some other use of the symbol.

llvm-svn: 119026
2010-11-14 04:17:37 +00:00
Rafael Espindola 0e3decfcf7 Simplify getSymbolIndexInSymbolTable by setting the actual index of
the symbols.

llvm-svn: 119022
2010-11-14 03:12:24 +00:00
Daniel Dunbar fe0c28f4db MC: Simplify Mach-O and ELF object writer implementations.
- What was I thinking?????

llvm-svn: 118992
2010-11-13 07:33:40 +00:00
Benjamin Kramer dcc7732f88 MCELF: Copy the symbol name only if we're going to modify it.
llvm-svn: 118920
2010-11-12 19:26:04 +00:00
Rafael Espindola a3e9a2298d Initial comdat implementation.
llvm-svn: 118805
2010-11-11 18:13:52 +00:00
Rafael Espindola fb6540c112 Make AliasedSymbol able to handle MCTargetExpr. They can get here if
a weakref is used with a VariantKind.

llvm-svn: 118798
2010-11-11 17:24:43 +00:00
Rafael Espindola fa7b55754c Fix the symbol index of weak references. Also make RecordRelocation a bit
easier to read by having const references to the symbol, aliased symbol and
renamed symbol.

llvm-svn: 118793
2010-11-11 16:48:11 +00:00
Rafael Espindola 19fa38000a Remove some explicit arguments to getELFSection. This is
a leftover from the removal of isExplicit.

llvm-svn: 118774
2010-11-11 03:40:25 +00:00
Rafael Espindola 5a8d781caa Factor some code into WriteSection.
llvm-svn: 118733
2010-11-10 23:36:59 +00:00
Rafael Espindola eb97f59753 Update the section index map after we add the medatada sections.
llvm-svn: 118728
2010-11-10 22:34:07 +00:00
Rafael Espindola 1801410fa8 Use SectionIndexMap in WriteSymbolTable to make it a little less brittle.
llvm-svn: 118725
2010-11-10 22:16:43 +00:00
Rafael Espindola d634003ebd Factor some code into ComputeIndexMap.
llvm-svn: 118722
2010-11-10 21:51:05 +00:00
Rafael Espindola 51d68339a2 Change the String<size> methods to take a fragment instead of a buffer.
llvm-svn: 118709
2010-11-10 20:02:59 +00:00
Rafael Espindola 36ef57d2eb Use MCSectionELF in places we know we have an ELF section.
llvm-svn: 118699
2010-11-10 19:05:07 +00:00
Rafael Espindola 9bb44a5ce8 Fixed version of 118639 with an extra assert to catch similar problems
earlier. Implicit bool -> int conversions are evil!

llvm-svn: 118651
2010-11-09 23:42:07 +00:00
Rafael Espindola 33048f069f Revert previous patch. Missed a case.
llvm-svn: 118645
2010-11-09 22:54:38 +00:00
Rafael Espindola 4bdd2724e3 Remove IsExplicit. It was always false.
llvm-svn: 118639
2010-11-09 22:37:44 +00:00
Rafael Espindola 1614597873 Implement .weakref.
llvm-svn: 117911
2010-11-01 14:28:48 +00:00
Rafael Espindola 3fe87a1eed Add support for files with more than 65280 sections. No testcase since
it would be a bit too big :-)

llvm-svn: 117849
2010-10-31 00:16:26 +00:00
Rafael Espindola 45834a0065 Be more strict on when we produce an undefined reference. In gas a file with
just

.type   foo,@object

will produce an undefined reference to foo. On the other hand, a file with
just

.weakref bar, foo

will not. It is somewhat hard to support both in MC since both statements
should create the symbols. It should be possible if we really need to by
adding to the flags, but hopefully that is not necessary.

With this patch we do not produce a undefined reference in any of those cases.
The assembly file needs an actual use for the undefined reference to be
present.

This is in preparation for a patch implementing .weakref.

llvm-svn: 117735
2010-10-29 23:09:31 +00:00
Rafael Espindola 3c5a54e4b9 Defined weak symbols should have non-zero value.
llvm-svn: 117585
2010-10-28 19:39:57 +00:00
Rafael Espindola 29f70afbae Fix relocations with renamed symbols.
llvm-svn: 117575
2010-10-28 19:08:03 +00:00
Rafael Espindola 6cd76e63f8 Aliases defined with .symver should copy the binding of the symbols they alias.
Move the existing patching for undefined symbols so that all the patching
is done in the same function.

llvm-svn: 117570
2010-10-28 18:33:03 +00:00
Rafael Espindola 936ba3af28 Implement R_X86_64_DTPOFF32.
llvm-svn: 117548
2010-10-28 15:11:03 +00:00
Rafael Espindola 2dbec3f762 Implement TLSLD.
llvm-svn: 117547
2010-10-28 15:02:40 +00:00
Rafael Espindola e8f08be11c Implement DTPOFF.
llvm-svn: 117546
2010-10-28 14:48:59 +00:00
Rafael Espindola 6f23eb380d Implement TLSLDM.
llvm-svn: 117544
2010-10-28 14:37:09 +00:00
Rafael Espindola b3b49bbc39 Implement VK_GOTNTPOFF and switch RelocNeedsGOT to use VariantKind.
llvm-svn: 117543
2010-10-28 14:22:44 +00:00
Rafael Espindola f8537165bd Add support for R_386_TLS_GD, R_386_TLS_LE_32, R_386_TLS_IE and R_386_TLS_LE.
llvm-svn: 117494
2010-10-27 21:23:52 +00:00
Rafael Espindola 24c8b04d5f Implement R_X86_64_GOTTPOFF, R_X86_64_TLSGD and R_X86_64_TPOFF32.
llvm-svn: 117481
2010-10-27 20:28:07 +00:00
Benjamin Kramer 14807270be Replace pointer arithmetic with StringRef::substr.
llvm-svn: 117477
2010-10-27 19:53:52 +00:00
Rafael Espindola 26496e6835 Produce an error for an invalid use of .symver.
llvm-svn: 117462
2010-10-27 17:56:18 +00:00
Rafael Espindola cc1b168ef6 Symbols defined as the difference of other two end up in the ABS section.
llvm-svn: 117451
2010-10-27 16:04:30 +00:00
Rafael Espindola eb0c2c170d Add support for the .symver directive. This is really ugly, but most of it is
contained in the ELF object writer.

llvm-svn: 117448
2010-10-27 15:18:17 +00:00
Rafael Espindola a5efd6a27c Move more logic to isInSymtab and simplify.
llvm-svn: 117447
2010-10-27 14:44:52 +00:00
Rafael Espindola 0ed1543d4e Add support for emitting ARM file attributes.
llvm-svn: 117275
2010-10-25 17:50:35 +00:00
Rafael Espindola 800fd3533c Add X86::reloc_global_offset_table and use it to have a single place where
we check for _GLOBAL_OFFSET_TABLE_.

llvm-svn: 117241
2010-10-24 17:35:42 +00:00
Wesley Peck 1851090515 Making the e_machine configurable by the target backend in ELFObjectWriter.
llvm-svn: 117099
2010-10-22 15:52:49 +00:00
Rafael Espindola ee8d15157a Small cleanups and fixes in preparation for fixing _GLOBAL_OFFSET_TABLE_.
llvm-svn: 116848
2010-10-19 19:31:37 +00:00