Commit Graph

119 Commits

Author SHA1 Message Date
Jim Grosbach
4750020788 ARM Fixups relative to thumb functions need to have the low bit of the value
set for interworking to work properly. rdar://8755956

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121778 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-14 18:46:57 +00:00
Rafael Espindola
89b9372605 Fixed version of 121434 with no new memory leaks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121471 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 07:39:47 +00:00
Rafael Espindola
f7fd4aa261 Revert my previous patch to make the valgrind bots happy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121461 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 04:01:09 +00:00
Rafael Espindola
1c952b9cc9 Initial support for the cfi directives. This is just enough to get
f:
        .cfi_startproc
        nop
        .cfi_endproc

assembled (on ELF).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121434 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 23:48:29 +00:00
Jim Grosbach
5be6d2af38 Let target asm backends see assembler flags as they go by. Use that to handle
thumb vs. arm mode differences in WriteNopData().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121219 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-08 01:16:55 +00:00
Rafael Espindola
85f2ecc697 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121076 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 00:27:36 +00:00
Rafael Espindola
32a006e606 Try to resolve symbol differences early, and if successful create a plain
data fragment. This reduces the time to assemble the test in 8711 from 60s to
54s.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120767 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 00:55:40 +00:00
Rafael Espindola
e23930543c Move EmitValueToOffset to the ObjectStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120691 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 05:59:38 +00:00
Rafael Espindola
dedb045c32 Add EmitInstToFragment to the generic object streamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120690 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 05:44:06 +00:00
Rafael Espindola
6f95023a7f Move EmitValue to MCObjectStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120269 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-28 23:08:47 +00:00
Rafael Espindola
ea4afa91eb Fixed verson of r120245.
Factor some duplicated code into MCObjectStreamer::EmitLabel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-28 17:18:55 +00:00
Rafael Espindola
ba210243ef Revert previous patch while I debug the darwin bootstrap failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120246 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-28 16:22:59 +00:00
Rafael Espindola
f90a2de72c Factor some duplicated code into MCObjectStreamer::EmitLabel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120245 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-28 15:54:36 +00:00
Rafael Espindola
3e03211625 Avoid code duplication in the many unsupported EmitGPRel32Value implementations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120243 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-28 15:09:24 +00:00
Rafael Espindola
e04ed7e45f 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120240 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-28 14:17:56 +00:00
Kevin Enderby
e8e98d7f2e Added support for the Mach-O .symbol_resolver directive. rdar://8673046
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-19 18:39:33 +00:00
Rafael Espindola
195a0ce484 Change some methods in MCDwarf.cpp to be able to handle an arbitrary
MCStreamer instead of just MCObjectStreamer. Address changes cannot
be as efficient as we have to use DW_LNE_set_addres, but at least
most of the logic is shared.

This will be used so that, with CodeGen still using EmitDwarfLocDirective,
llvm-gcc is able to produce debug_line sections without needing an
assembler that supports .loc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119777 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-19 02:26:16 +00:00
Rafael Espindola
af6b580875 Add .loc methods to the streamer.
Next: Add support for the !HasDotLocAndDotFile case to the MCAsmStreamer
and then switch codegen to use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119384 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-16 21:20:32 +00:00
Rafael Espindola
e13a0ff8ac Parse and record the gnu_unique_object type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118980 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-13 04:51:02 +00:00
Jim Grosbach
ba21957cbd Add '.code 32' assembler directive to MC streamers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118309 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-05 22:40:09 +00:00
Jim Grosbach
ce79299f78 MC'ize the '.code 16' and '.thumb_func' ARM directives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118301 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-05 22:08:08 +00:00
Jim Grosbach
41ed3ca19d syntaxunified directive is a no-op for MachO writing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118287 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-05 18:47:32 +00:00
Rafael Espindola
f89671d994 Move EmitInstruction to MCObjectStreamer so that ELF and MachO can share it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117925 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-01 16:27:31 +00:00
Kevin Enderby
8c9aa922a9 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115389 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-02 00:13:41 +00:00
Kevin Enderby
c095793b4a This is the last major patch to implement support for the .loc directive
and output the dwarf line number tables.  This contains the code to emit and
encode the dwarf line tables from the previously gathered information in the
MCLineSection objects.  This contains all the details to encode the line and
address deltas into the dwarf line table.

To do this an MCDwarfLineAddrFragment has been added.

Also this moves the interface code out of Mach-O streamer into
MCDwarf so it should be useable by other object file formats.

There is now one call to be made from an MCObjectStreamer
EmitInstruction() method:
   MCLineEntry::Make(this, getCurrentSection());
to create a line entry after each instruction is assembled.

And one call call to be made from an MCObjectStreamer Finish() method:
   MCDwarfFileTable::Emit(this, DwarfLineSection);
when getContext().hasDwarfFiles() is true and is passed a object file specific
MCSection where to emit the dwarf file and the line tables.

This appears to now be correct for 32-bit targets, at least x86.  But the
relocation entries for 64-bit Darwin needs some further work which is next
up to work on.  So for now the 64-bit Mach-O target does not output the
dwarf file and line tables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115157 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 16:52:03 +00:00
Chandler Carruth
5c0d472b6e Silence a GCC warning about not handling all flags in this switch, we
specifically assert on unexpected flags.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 10:59:51 +00:00
Rafael Espindola
59ff3c9134 Avoid some Mach-O specific alignment being done on ELF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-22 22:27:05 +00:00
Rafael Espindola
d80781b98b Add a InitSections method to the streamer interface.
The ELF implementation now creates text, data and bss to match the gnu as
behavior.

The text streamer still has the old MachO specific behavior since
the testsuite checks that it will error when a directive is given
before a setting the current section for example.

A nice benefit is that -n is not required anymore when producing
ELF files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114027 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-15 21:48:40 +00:00
Bill Wendling
7d49f2b1bf Get rid of "passing signed into unsigned parameter" warning on PPC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112995 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 19:09:46 +00:00
Kevin Enderby
232ab949d5 This is the second of three patches to implement support for the .loc directive
and output the dwarf line number tables.  This takes the current loc info after
an instruction is assembled and saves the needed info into an object that has
vector and for each section.  These objects will be used for the final patch to 
build and emit the encoded dwarf line number tables.  Again for now this is only
in the Mach-O streamer but at some point will move to a more generic place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112668 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 22:55:11 +00:00
Kevin Enderby
b07ce60981 Next bit of support for the dwarf .file directive. This patch takes the
previously collected info from the .file directives and outputs the encoded
bytes for it.  For now this is only in the Mach-O streamer but at some point
will move to a more generic place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110617 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-09 22:52:14 +00:00
Daniel Dunbar
96749678c9 MC/Mach-O: Silently ignore .file directives instead of error'ing out on
them. They aren't important enough to abort the entire assembly, and failing
early makes testing more annoying.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108747 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-19 20:44:20 +00:00
Michael J. Spencer
8067adc271 MC: Add WinCOFFStreamer implementation and merge common code from MachO
into MCObjectStreamer.

Origonal Windows COFF implementation by Nathan Jedffords.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108678 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-19 06:13:10 +00:00
Kevin Enderby
f59cac5ed3 Added the darwin .weak_def_can_be_hidden directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107886 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-08 17:22:42 +00:00
Daniel Dunbar
a86de10508 MC/Mach-O: Rewrite atom association to be a final pass we do in Finish(), instead of tracking as part of emission.
- This allows sharing more code with the MCObjectStreamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 20:04:32 +00:00
Daniel Dunbar
843aa1f15b MC: Simplify MCAssembler::isSymbolLinkerVisible to only take an MCSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106142 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 20:04:29 +00:00
Daniel Dunbar
83b467178a MC: Lift SwitchSection() and Finish() into MCObjectStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106141 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 20:04:25 +00:00
Daniel Dunbar
8dc68ab931 MC: Factor out an MCObjectStreamer class, which will be shared by the concrete
object file format writers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106140 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 20:04:22 +00:00
Daniel Dunbar
83194de76a MC: When running with -mc-relax-all, we can eagerly relax instructions and avoid creating unnecessary MCInstFragments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104736 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 20:37:03 +00:00
Daniel Dunbar
2ac0c453b2 MC/Mach-O: Factor out EmitInstTo{Fragment,Data} for emitting MCInst's as MCInstFragments or appending onto an MCDataFragment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104735 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 20:37:00 +00:00
Daniel Dunbar
dae5b9f804 MC: Eliminate an unnecessary copy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 17:50:16 +00:00
Daniel Dunbar
8488252855 MC: Simplify MayNeedRelaxation to not provide the fixups, so we can query it
before encoding.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104707 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 17:45:29 +00:00
Daniel Dunbar
c90e30aa6f MC: Eliminate MCAsmFixup, replace with MCFixup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104699 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 15:18:56 +00:00
Daniel Dunbar
482ad802f1 MC: Use accessors for access to MCAsmFixup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104697 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 15:18:31 +00:00
Eric Christopher
070c1abbc9 Expand on comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104396 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-21 23:03:53 +00:00
Eric Christopher
011c3f110b Implement EmitTBSSSymbol for MachOStreamer.
Fixes build failure as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104059 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18 21:26:41 +00:00
Daniel Dunbar
2ae4bfd769 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104033 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18 17:28:24 +00:00
Daniel Dunbar
ca1212de59 MC/Mach-O: Fail faster/harder when we see .file, which isn't yet supported.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104031 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18 17:28:17 +00:00
Daniel Dunbar
db9014dd8b MC/Mach-O: Reverse order of SymbolData scanning when emitting instructions.
- This fixes a string table mismatch with 'as' when two new symbols are defined
   in a single instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103979 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-17 21:19:59 +00:00
Daniel Dunbar
b18d2dd115 MC/Mach-O: Fix some differences in symbol flag handling.
- Don't clear weak reference flag, 'as' was only "trying" to do this, it wasn't
   actually succeeding.
 - Clear the "lazy bound" bit when we mark something external. This corresponds
   roughly to the lazy clearing of the bit that 'as' implements in
   symbol_table_lookup.
 - The exact meaning of these flags appears pretty loose, since 'as' isn't very
   consistent. For now we just try to match 'as', we will clean this up one day
   hopefully.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103964 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-17 20:12:31 +00:00