1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

222 Commits

Author SHA1 Message Date
Daniel Dunbar
2caf23b5a9 MC/ObjectWriter: Add a new IsSymbolRefDifferenceFullyResolved target format specific hook.
- Currently just has stub implementations for Mach-O, ELF, and COFF.

llvm-svn: 122037
2010-12-17 04:54:54 +00:00
Daniel Dunbar
f77af712b7 MC/Assembler: Strip out object writer arguments, now that it is always available
-- and remove FIXME asking for the same!

llvm-svn: 122032
2010-12-17 02:45:59 +00:00
Daniel Dunbar
6d4a3e98f3 MC/Target: Remove HasScatteredSymbols target hook variable, which has been
superceded and was effectively dead.

llvm-svn: 122024
2010-12-17 02:06:08 +00:00
Daniel Dunbar
2277f06687 MC/Mach-O: Lift some MachObjectWriter arguments into the target specific
interface.

llvm-svn: 121981
2010-12-16 17:21:02 +00:00
Daniel Dunbar
5fee4f6862 MC/Mach-O: Stub out explicit MCMachObjectTargetWriter interface.
llvm-svn: 121973
2010-12-16 16:09:19 +00:00
Daniel Dunbar
636e690f58 MC/Mach-O: Move createMachObjectWriter into MCMachObjectWriter.h.
llvm-svn: 121971
2010-12-16 16:08:33 +00:00
Daniel Dunbar
af109884b9 MC/Mach-O: Use fixup info instead of hard coded list.
llvm-svn: 121970
2010-12-16 15:42:31 +00:00
Rafael Espindola
866531d633 Fix absolute recording of differences of symbols in two sections. Reduced from ctor_dtor_count-2.cpp.
llvm-svn: 121152
2010-12-07 17:12:32 +00:00
Rafael Espindola
da64b6aa50 Fix relocations with weak definitions.
llvm-svn: 121114
2010-12-07 05:57:28 +00:00
Rafael Espindola
9ede5ef045 Fix pcrel relocations that cross sections.
llvm-svn: 121107
2010-12-07 03:50:14 +00:00
Rafael Espindola
c98cc0b286 Fix a crash reduced from gcc produced assembly.
llvm-svn: 121085
2010-12-07 01:09:54 +00:00
Rafael Espindola
8dad37785c Sorry for such a large commit. The summary is that only MachO cares about the
actuall addresses in a .o file, so it is better to let the MachO writer compute
it.

This is good for two reasons. First, areas that shouldn't care about
addresses now don't have access to it. Second, the layout of each section
is independent. I should use this in a subsequent commit to speed it up.

Most of the patch is just removing the section address computation. The two
interesting parts are the change on how we handle padding in the end
of sections and how MachO can get the address of a-b when a and b are in
different sections.

Since now the expression evaluation normally doesn't know the section address,
it will think that a-b needs relocation and let the MachO writer know. Once
it has computed the section addresses, it calls back the expression evaluation
with the section addresses to resolve these expressions.

The remaining problem is the handling of padding. Currently it will create
a special alignment fragment at the end. Since that fragment doesn't update
the alignment of the section, it needs the real address to be computed.

Since now the layout will not compute a-b with a and b in different sections,
the only effect that the special alignment fragment has is update the
address size of the section. This can also be done by the MachO writer.

llvm-svn: 121076
2010-12-07 00:27:36 +00:00
Rafael Espindola
c726be7d0a use getSymbolOffset.
llvm-svn: 121041
2010-12-06 21:51:55 +00:00
Rafael Espindola
fd0cc5d13f Another use of getSymbolOffset.
llvm-svn: 121034
2010-12-06 19:55:05 +00:00
Jim Grosbach
0e71db6919 Add support for binary encoding of ARM 'adr' instructions referencing constant
pool entries (LEApcrel pseudo). Ongoing saga of rdar://8542291.

llvm-svn: 120635
2010-12-02 00:28:45 +00:00
Rafael Espindola
f77005db2b Define generic 1, 2 and 4 byte pc relative relocations. They are common
and at least the 4 byte one will be needed to implement the .cfi_* directives.

llvm-svn: 120240
2010-11-28 14:17:56 +00:00
Daniel Dunbar
2dd3ae7c9c macho-dump: Add support for dumping relocation entries.
llvm-svn: 120216
2010-11-27 13:39:48 +00:00
Daniel Dunbar
a9f9d6d2db Fix a comment.
llvm-svn: 120199
2010-11-27 07:39:37 +00:00
Daniel Dunbar
9b9f0a4d16 Reduce nesting.
llvm-svn: 120189
2010-11-27 05:18:48 +00:00
Daniel Dunbar
c686ff034f MC/Mach-O: Migrate more constants into MachOFormat.h.
llvm-svn: 120188
2010-11-27 04:59:14 +00:00
Daniel Dunbar
f050a00c17 MC/Mach-O: Introduce Object/MachOFormat for describing purely platform / machine
independent information on the Mach object format, and move some stuff from
MachObjectWriter.cpp there.

llvm-svn: 120186
2010-11-27 04:19:38 +00:00
Rafael Espindola
7fc5cd0a58 make isVirtualSection a virtual method on MCSection. Chris' suggestion.
llvm-svn: 119547
2010-11-17 20:03:54 +00:00
Daniel Dunbar
2ba9f79194 MC: Simplify Mach-O and ELF object writer implementations.
- What was I thinking?????

llvm-svn: 118992
2010-11-13 07:33:40 +00:00
Jim Grosbach
b48a272807 Trailing whitespace.
llvm-svn: 118831
2010-11-11 20:16:23 +00:00
Jim Grosbach
a85416eb77 Allow targets to specify the MachO CPUType/CPUSubtype information.
llvm-svn: 118288
2010-11-05 18:48:58 +00:00
Rafael Espindola
5f53528867 On ELF we need to know which symbols are used in relocations to decide if
they should be in the symbol table or not. Instead of "guessing", just compute
the symbol table after the relocations are known.

llvm-svn: 115619
2010-10-05 15:11:03 +00:00
Kevin Enderby
84d750a85c This adds a Darwin x86_64 relocation encoding for a subtraction expression
where both symbols are "local", that is non-external symbols, and there is
no "base" for the symbols used in the expression, that is the section has
no non-temporary symbols.  This case looks like this:

% cat local_reloc_A-B.s
	.long 0
LB:	.long 1
	.long LA - LB - 4
	.long 2
LA:	.long 3

which llvm-mc will not encode without this patch, generates a "unsupported
local relocations in difference" error, but the Darwin assembler will
encode with relocation entries like this:

% otool -rv a.out l.out 
a.out:
Relocation information (__TEXT,__text) 2 entries
address  pcrel length extern type    scattered symbolnum/value
00000008 False long   False  SUB     False     1 (__TEXT,__text)
00000008 False long   False  UNSIGND False     1 (__TEXT,__text)

which is very similar to what is encoded when the symbols don't have the
leading 'L' and they are not temporary symbols.  Which llvm-mc and the
Darwin assembler will encoded like this:

Relocation information (__TEXT,__text) 2 entries
address  pcrel length extern type    scattered symbolnum/value
00000008 False long   True   SUB     False     B
00000008 False long   True   UNSIGND False     A

This is the missing relocation encoding needed to allow the Mach-O x86
Dwarf file and line table to be emitted.  So this patch also removes the
TODO from the if() statement in MCMachOStreamer::Finish() that didn't 
call MCDwarfFileTable::Emit() for 64-bit targets.

llvm-svn: 115389
2010-10-02 00:13:41 +00:00
Rafael Espindola
480ee577ad 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
3e2630deca 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
843df9bbed Remove unused argument.
llvm-svn: 114852
2010-09-27 18:13:03 +00:00
Daniel Dunbar
ed92665b19 MC/Mach-O/i386: Fix a crash in relocation handling.
llvm-svn: 114176
2010-09-17 15:21:50 +00:00
Chris Lattner
e51188af11 silence a vc2010 warning: " result of 32-bit shift implicitly converted to
64 bits (was 64-bit shift intended?)", pointed out by 'nobled' on llvmdev

llvm-svn: 111148
2010-08-16 16:35:20 +00:00
Michael J. Spencer
26a45fe57e Revert "MC/MachO: Fix possible null pointer dereference."
This reverts commit 110575.

Target.isAbsolute() is true if SD would be null.

llvm-svn: 110683
2010-08-10 16:00:49 +00:00
Michael J. Spencer
72463de287 MC/MachO: Fix possible null pointer dereference.
Discovered by Microsoft Visual Studio 2010 Code Analysis.

llvm-svn: 110575
2010-08-09 15:28:05 +00:00
Chris Lattner
155420f59f finish up support for callw: PR7195
llvm-svn: 107826
2010-07-07 22:35:13 +00:00
Duncan Sands
5446bab8a5 The variable "Value" is carefully set to Layout.getSymbolAddress,
but then not actually used - maybe a bug?  Remove the variable.

llvm-svn: 107137
2010-06-29 13:26:33 +00:00
Eric Christopher
0c4230b33c Get the addend correct for i386 pic.
Thanks Daniel!

llvm-svn: 106608
2010-06-22 23:51:47 +00:00
Eric Christopher
b92292eb08 Update comment.
llvm-svn: 106191
2010-06-17 00:49:46 +00:00
Eric Christopher
9c56c0a851 In progress on 32-bit addends.
llvm-svn: 106154
2010-06-16 21:32:38 +00:00
Daniel Dunbar
2c6d6693e2 MC: Simplify MCAssembler::isSymbolLinkerVisible to only take an MCSymbol.
llvm-svn: 106142
2010-06-16 20:04:29 +00:00
Eric Christopher
62a7f68562 Fix indentation.
llvm-svn: 106072
2010-06-16 00:26:36 +00:00
Eric Christopher
6c154dc98d Some more work on mach-o TLV relocations.
llvm-svn: 106062
2010-06-15 22:59:05 +00:00
Eric Christopher
405e56fdfb Rearrange conditionals so we don't get caught with the correct type as wrong.
llvm-svn: 104793
2010-05-27 00:52:31 +00:00
Daniel Dunbar
87dcbd1ee5 MC: Eliminate MCAsmFixup, replace with MCFixup.
llvm-svn: 104699
2010-05-26 15:18:56 +00:00
Daniel Dunbar
55c1bf55fe MC: Use accessors for access to MCAsmFixup.
llvm-svn: 104697
2010-05-26 15:18:31 +00:00
Eric Christopher
371732bd2a Start adding mach-o tls reloc support.
llvm-svn: 104651
2010-05-26 00:02:12 +00:00
Benjamin Kramer
47bf53a5dd Reduce string trashing.
llvm-svn: 104223
2010-05-20 14:14:22 +00:00
Daniel Dunbar
739e720a21 MC/Mach-O: Implement support for setting indirect symbol table offset in section header.
Also, create symbol data for LHS of assignment, to match 'as' symbol ordering better.

llvm-svn: 104033
2010-05-18 17:28:24 +00:00
Daniel Dunbar
9a1bbd9dc5 MC/Mach-O: Remove some FIXMEs.
llvm-svn: 104032
2010-05-18 17:28:20 +00:00
Daniel Dunbar
89a1d9036a MC/Mach-O/x86_64: Darwin's special "signed_N" relocation types should only be
used to replace a normal relocation, not a reference to a GOT entry.

llvm-svn: 103789
2010-05-14 18:53:40 +00:00
Daniel Dunbar
a033860d55 MC/Mach-O/x86_64: Fix PCrel adjustment for x86_64, which was using the fixup
offset instead of the fixup address as intended.

llvm-svn: 103527
2010-05-11 23:53:11 +00:00
Daniel Dunbar
7d7b6cf3b7 MC/Mach-O: As Kevin pointed out, 'Address' is really an offset -- rename to clarify.
llvm-svn: 103526
2010-05-11 23:53:07 +00:00
Daniel Dunbar
e43676c164 MC/Mach-O: Fix a crash on invalid.
llvm-svn: 103525
2010-05-11 23:53:05 +00:00
Daniel Dunbar
d2c14ce38d MC/Mach-O: Fix another mismatch with .weak_definition, we shouldn't use a
scattered relocation entry with a .weak_definition.

llvm-svn: 103443
2010-05-10 23:15:20 +00:00
Daniel Dunbar
c54539c121 MC/Mach-O: Factor out doesSymbolRequireExternRelocation.
llvm-svn: 103442
2010-05-10 23:15:13 +00:00
Kevin Enderby
3807a4746a Fix i386 relocations to Weak Definitions. The relocation entries should be
external and the item to be relocated should not have the address of the
symbol added in.

llvm-svn: 103302
2010-05-07 21:44:23 +00:00
Daniel Dunbar
9a3d46162f MC/Mach-O: Mark absolute variable's appropriately, and add Mach-O support for
writing them.
 - <rdar://problem/7885351> integrated assembler broken for i386 objc code

llvm-svn: 103112
2010-05-05 19:01:05 +00:00
Daniel Dunbar
f5dc70a7d1 MC/Mach-O/x86_64: Relocations in debug sections should use local relocations
when possible.
 - <rdar://problem/7934873>

llvm-svn: 103092
2010-05-05 17:22:39 +00:00
Benjamin Kramer
3b7602b1fb Various MSVC warning fixes about truncated 64 bit shifts and const pointers passed to free.
llvm-svn: 100767
2010-04-08 15:25:57 +00:00
Chris Lattner
80b41881bc rename llvm::llvm_report_error -> llvm::report_fatal_error
llvm-svn: 100709
2010-04-07 22:58:41 +00:00
Daniel Dunbar
f2c7999cd8 MC/Mach-O/x86_64: Support @GOTPCREL on symbols, even for non-PCrel relocations!
llvm-svn: 99853
2010-03-29 23:56:40 +00:00
Daniel Dunbar
f793969cd1 MC/Mach-O: Switch to MCSectionData::getOrdinal.
llvm-svn: 99504
2010-03-25 08:08:54 +00:00
Daniel Dunbar
276acc64a9 Fix -Asserts warning.
llvm-svn: 99499
2010-03-25 07:10:05 +00:00
Daniel Dunbar
797b44b26c MC: Route access to SectionData offset and file size through MCAsmLayout.
llvm-svn: 99474
2010-03-25 02:00:07 +00:00
Daniel Dunbar
4b6b2a1a1f MC: Route access to Fragment offset and effective size through MCAsmLayout.
llvm-svn: 99473
2010-03-25 02:00:02 +00:00
Daniel Dunbar
3a79d30c6c MC: Direct all {fragment,section,symbol} address access through the MCAsmLayout object.
llvm-svn: 99380
2010-03-24 03:43:40 +00:00
Daniel Dunbar
1836f73559 Add a FIXME.
llvm-svn: 99228
2010-03-22 23:16:43 +00:00
Daniel Dunbar
6a91d2767b MC: Change MCObjectWriter::RecordRelocation to take an MCFragment (instead of a MCDataFragment). Object files should only need the generic MCFragment features.
llvm-svn: 99205
2010-03-22 20:35:50 +00:00
Daniel Dunbar
6b3e18d2c4 Better fix for r98994, MachObjectWriterImpl wasn't intended to be virtual.
llvm-svn: 99031
2010-03-20 01:58:40 +00:00
Rafael Espindola
5b074c72ee Fix -Wnon-virtual-dtor warning.
llvm-svn: 98994
2010-03-19 21:26:46 +00:00
Daniel Dunbar
3c66c7a3c1 MC/Mach-O/x86_64: Add relocation support.
- This is "extraordinarily" Darwin 'as' compatible. See the litany of FIXMEs littered about for more information.
 - There are a few cases which seem to clearly be 'as' bugs which I have left unsupported, and there is one cases where we diverge but should fix if it blocks diffing .o files (Darwin 'as' ends up widening a jump unnecessarily).
 - 403.gcc build, runs, and diffs equivalently to the 'as' built version now (using llvm-mc). However, it builds so slowly that I wouldn't recommend trying it quite yet. :)

llvm-svn: 98974
2010-03-19 18:07:55 +00:00
Daniel Dunbar
74330a6389 MC/Mach-O: Move to MachObjectWriter.{h,cpp}.
llvm-svn: 98952
2010-03-19 10:43:15 +00:00