Commit Graph

1361 Commits

Author SHA1 Message Date
Charles Davis 27117af772 Remove comments as Chris requested.
llvm-svn: 131590
2011-05-18 22:13:51 +00:00
Cameron Zwarich 492f87de4e Fix an obvious typo in r131572.
llvm-svn: 131579
2011-05-18 21:29:07 +00:00
Charles Davis 77e0610d7c Add some more Win64 EH directives:
- StartChained and EndChained delimit a chained unwind area, which can contain
  additional operations to be undone if an exception occurs inside of it.
- UnwindOnly declares that this function doesn't handle any exceptions. If it
  has a handler, it's an unwind handler instead of an exception handler.
- Lsda declares the location and size of the LSDA, which in the Win64 EH
  scheme is kept inside the UNWIND_INFO struct. Windows itself ignores the
  LSDA; it's used by the Language-Specific Handler (the "Personality Function"
  from DWARF).

llvm-svn: 131572
2011-05-18 20:54:10 +00:00
Charles Davis 8d9c99042f Implement the Win64 EH directive methods for the assembly language streamer.
GAS has no such directives (not even mingw-w64 GAS has them), so I took
creative license with their names in assembly. I prefixed them all with
"w64_" to avoid namespace collisions, for example. If I discover that GAS
has taken a different approach, I'll change ours to match.

llvm-svn: 131525
2011-05-18 04:58:05 +00:00
Charles Davis 384041d0dc While thinking about how to know where the functions' boundaries are for
the purposes of the Win64 EH tables, I realized we had no way to tell where
the function ends. (MASM bounds functions with PROC and ENDP keywords.)
Add a directive to delimit the end of the function, and rename the 'frame'
directive to more accurately reflect its duality with the new directive.

llvm-svn: 131522
2011-05-18 04:47:22 +00:00
Charles Davis 2701815ed8 Add a method I forgot in the last commit. Don't worry, this one passed
self-host :).

llvm-svn: 131421
2011-05-16 21:13:58 +00:00
Jason W Kim 94c31fdd31 Add a FIXME reminder to remove ForceARMElfPIC switch.
llvm-svn: 131411
2011-05-16 16:35:21 +00:00
Rafael Espindola e90c1cb221 sets bit 0 of the function address of thumb function in .symtab
("T is 1 if the target symbol S has type STT_FUNC and the
symbol addresses a Thumb instruction ;it is 0 otherwise."
from "ELF for the ARM Architecture" 4.7.1.2)

Patch by Koan-Sin Tan!

llvm-svn: 131406
2011-05-16 16:17:21 +00:00
Charles Davis 2f10078ae7 Fix copy-pasto.
llvm-svn: 131384
2011-05-15 17:28:27 +00:00
Charles Davis af18d07ed6 Add stub methods to MCStreamer for emitting Win64 exception-handling
information.

llvm-svn: 131382
2011-05-15 17:20:01 +00:00
Matt Beaumont-Gay 7c6c90b35d Remove an unused variable and move a couple others inside DEBUG.
llvm-svn: 131208
2011-05-11 23:34:51 +00:00
Jason W Kim c09e726455 Address the last bit of relocation flag related divergence betweeen
LLVM and binutils.

With this patch, there are no functional differences between the .o
produced directly from LLVM versus the .s to .o via GNU as, for relocation tags
at least, for both PIC and non-PIC modes.

Because some non-PIC reloc tags are used (legally) on PIC, so IsPCRel flag is
necessary but not sufficient to determine whether the overall codegen mode is
PIC or not. Why is this necessary? There is an incompatibility of how relocs
are emitted in the .rodata section.  Binutils PIC likes to emit certain relocs
as section relative offsets.  Non-PIC does not do this.

So I added a hidden switch on the ELFObjectwriter "-arm-elf-force-pic" which
forces the objectwriter to pretend that all relocs are for PIC mode.


Todo: Activate ForceARMElfPIC to true if -relocation-model=pic is selected
on llc.

Todo: There are probably more issues for PIC mode on ARM/MC/ELF...

Todo: Existing tests in MC/ARM/elf-reloc*.ll need to be converted over to .s 
tests as well as expanded to cover the gamut.

llvm-svn: 131205
2011-05-11 22:53:06 +00:00
Rafael Espindola de32fa163f Avoid a gcc warning.
llvm-svn: 131161
2011-05-10 22:28:35 +00:00
Rafael Espindola 99f6735532 On MachO, unlike ELF, there should be no relocation to produce the CIE pointer.
llvm-svn: 131149
2011-05-10 20:59:42 +00:00
Rafael Espindola 2fe0ee1ce2 Rename DwarfRequiresRelocationForStmtList to
DwarfRequiresRelocationForSectionOffset as this is not specific to StmtList.

llvm-svn: 131148
2011-05-10 20:35:05 +00:00
Rafael Espindola d0d2354258 The EH symbols are only needed in eh_frame, not debug_frame.
llvm-svn: 131146
2011-05-10 19:51:53 +00:00
Rafael Espindola 27390b4a0e In a debug_frame the cfi offset is to the start of the debug_frame section!
llvm-svn: 131129
2011-05-10 15:20:23 +00:00
Rafael Espindola ec53aa9485 Add CFIStartSections to the asm printer. Add an assert that at least
one of the sections is created.

llvm-svn: 131124
2011-05-10 13:39:48 +00:00
Rafael Espindola 1ecb12fc57 Add support for producing .deubg_frame sections.
llvm-svn: 131121
2011-05-10 03:54:12 +00:00
Rafael Espindola b6444c0401 Small cleanups.
llvm-svn: 131120
2011-05-10 03:26:21 +00:00
Rafael Espindola b6089d6cac Factor some code into a new EmitFrames method.
llvm-svn: 131119
2011-05-10 03:14:15 +00:00
Rafael Espindola 0e130d1d37 Remove unused argument.
llvm-svn: 131118
2011-05-10 03:01:39 +00:00
Rafael Espindola 74b101f3e3 Parsing and plumbing for .cfi_sections.
llvm-svn: 131117
2011-05-10 01:10:18 +00:00
NAKAMURA Takumi 392445823d Eliminate an unused line to fix a warning.
llvm-svn: 131078
2011-05-08 23:19:04 +00:00
Rafael Espindola ab39c63538 Don't force relaxation of AdvanceLoc instructions on OS X. gdb is happy with
the smaller encoding and this cuts 270336 bytes from a release version of
clang and 1246272 bytes from a debug build.

llvm-svn: 131067
2011-05-08 14:35:21 +00:00
Rafael Espindola bcabcdcedd Switch Darwin to the generic CIE/FDE printer.
llvm-svn: 131031
2011-05-06 22:29:04 +00:00
Rafael Espindola a716096677 Dead code elimination.
llvm-svn: 130984
2011-05-06 14:56:22 +00:00
Rafael Espindola a4982bddf3 Don't produce a __debug_frame.
I tested both gdb on a bootstrapped clang and and the gdb testsuite on OS X (snow leopard)
and both are happy using __eh_frame.

llvm-svn: 130937
2011-05-05 18:43:39 +00:00
Rafael Espindola a75589171a Producing a DW_FORM_addr for DW_AT_stmt_list is probably correct, but
it is both inefficient and unexpected by dwarfdump. Change to
a DW_FORM_data4.

While in here, change the predicate name to reflect that the position
is not really absolute (it is an offset), just that the linker needs a
relocation.

llvm-svn: 130846
2011-05-04 17:44:06 +00:00
Daniel Dunbar f6daf94ab2 MCDwarf: Don't save Twine to local variable, this is almost never safe to do
(and should thus never be done).
 - Should fix a crash on win32.

llvm-svn: 130793
2011-05-03 21:33:37 +00:00
Rafael Espindola fc8223670a Add r130623 back now that ELF has been fixed to work with -fno-dwarf2-cfi-asm.
llvm-svn: 130658
2011-05-01 15:44:13 +00:00
Rafael Espindola 750cb61553 GCC uses a different encoding of pointers in the FDE when using
-fno-dwarf2-cfi-asm. Implement the same behavior.

llvm-svn: 130637
2011-05-01 04:49:54 +00:00
Rafael Espindola fd05785324 Simplify the handling of pcrel relocations on ELF. Now we do the right thing
for all symbol differences and can drop the old EmitPCRelSymbolValue
method.

This also make getExprForFDESymbol on ELF equal to the one on MachO, and it
can be made non-virtual.

llvm-svn: 130634
2011-05-01 03:50:49 +00:00
Rafael Espindola b7c2286055 Revert the previous patch while I figure out how to make llvm-gcc
less agressive about disabling cfi on linux :-(

llvm-svn: 130626
2011-04-30 23:03:44 +00:00
Rafael Espindola 5265bc483e Enable CFI on OS X.
Currently the output should be almost identical to the one produced by CodeGen
to make the transition easier.

The only two differences I know of are:

* Some files get an extra advance loc of size 0. This will be fixed when
relaxations are enabled.
* The optimization of declaring an EH symbol as an external variable is not
implemented. This is a subset of adding the nounwind attribute, so we if really
this at -O0 we should probably do it at the IL level.

llvm-svn: 130623
2011-04-30 22:29:54 +00:00
Rafael Espindola bde52bca69 Implement MCAsmStreamer::EmitEHSymAttributes. Doing this in the asm streamer
is a bit ugly, but doing it on the base MCStreamer would be redundant
with the object streamer which does it using SD.

llvm-svn: 130611
2011-04-30 16:34:57 +00:00
Rafael Espindola 0b474c2d15 Handle PrivateExtern eh symbols.
llvm-svn: 130609
2011-04-30 16:22:46 +00:00
Rafael Espindola a3181d12c6 Add all the plumbing needed for MC to expand cfi to the old tables in
the final assembly. It is the same technique used when targeting
assemblers that don't support .loc.

llvm-svn: 130587
2011-04-30 03:44:37 +00:00
Rafael Espindola 1d1eced025 Implement MCAsmStreamer::EmitDwarfAdvanceFrameAddr.
llvm-svn: 130585
2011-04-30 03:21:04 +00:00
Rafael Espindola 6a85f9b42e Avoid some uses of .uleb128. This is a small speedup and more importantly
lets this code be used when producing assembly code for old assemblers without
uleb support.

llvm-svn: 130544
2011-04-29 21:50:57 +00:00
Rafael Espindola 6c961e1b75 Implement MCAsmStreamer::EmitCFIDefCfa.
llvm-svn: 130543
2011-04-29 21:41:06 +00:00
Daniel Dunbar 72032861c6 MCAsmLayout: Add support for computing the symbol offset of variables. Not
currently used, because variables don't get reported as being "defined".

llvm-svn: 130524
2011-04-29 18:20:20 +00:00
Daniel Dunbar bea7b93c88 MC: Change variable symbols to be recognized as defined, by assigning their sections based on FindAssociatedSection().
llvm-svn: 130523
2011-04-29 18:20:17 +00:00
Daniel Dunbar b200f93125 MC/Mach-O: Update getSymbolAddress() to support evaluation of variables.
llvm-svn: 130522
2011-04-29 18:13:42 +00:00
Daniel Dunbar 29ba55cfe4 MC/Mach-O: Allow emission of relocations for variables in some more cases.
llvm-svn: 130520
2011-04-29 18:10:47 +00:00
Daniel Dunbar b9c2b6c50d MC/Mach-O: Find section ordinal's by looking at the symbol, instead of assuming they are present in a fragment.
llvm-svn: 130519
2011-04-29 18:07:43 +00:00
Devang Patel 124ae13421 Hoist MCLineEntry construction AsmPrinter so that anyone who derives from AsmPrinter can have line number entries.
PR 9810

llvm-svn: 130518
2011-04-29 18:00:54 +00:00
Daniel Dunbar dc3e4cc5ed MCExpr: Add FindAssociatedSection, which attempts to mirror the 'as' semantics
that associate sections with expressions.

llvm-svn: 130517
2011-04-29 18:00:03 +00:00
Daniel Dunbar 1bf128eaeb MC/AsmParser: Generalize a check.
llvm-svn: 130515
2011-04-29 17:53:11 +00:00
Rafael Espindola 68067664c3 Last bit by bit compatibility patch to MCDwarf.cpp: If a FDE with no LSDA is
assigned to a CIE that requires one, just output a 0.

llvm-svn: 130472
2011-04-29 03:06:29 +00:00
Rafael Espindola 7c7151512c Add an alternative implementation of CIE and FDE emission that outputs them
in the same order as the one in CodeGen.

llvm-svn: 130471
2011-04-29 02:42:28 +00:00
Rafael Espindola 6bd6a70837 Add the getExprForFDESymbol method that responsible for computing the
expressions used in the FDE to refer to symbols.

llvm-svn: 130437
2011-04-28 21:04:39 +00:00
Rafael Espindola c5dac4df2e Add a getExprForPersonalitySymbol method to MCAsmInfo. Use it when
converting the symbol passed to .cfi_personality into bytes is the file.

llvm-svn: 130400
2011-04-28 16:09:09 +00:00
Rafael Espindola 349c3298da Mark the EH symbol global or weak if the corresponding function is.
llvm-svn: 130397
2011-04-28 12:50:37 +00:00
Rafael Espindola 2eeee8cfef Add a small temporary hack for producing identical eh_frame sections on OS X.
This removes one of the main advantages of moving eh_frame to MC, but
makes the transition a lot easier to debug (run md5).

llvm-svn: 130379
2011-04-28 04:04:14 +00:00
Rafael Espindola bf60fb0a37 Produce the EH_frame# symbols if needed.
llvm-svn: 130378
2011-04-28 03:26:11 +00:00
Rafael Espindola 96b07932a3 Forward isFunctionEHFrameSymbolPrivate. If it is false, produce the foo.eh
symbols.

llvm-svn: 130375
2011-04-28 02:46:42 +00:00
Rafael Espindola 27c0c9bb87 Factor a bit of code to MCStreamer::EmitLabel. Keep track of the last
non private symbol. This will be use for handling

foo:
  .cfi_startproc
  ...

On OS X where we have to create a foo.eh symbol.

llvm-svn: 130305
2011-04-27 15:21:19 +00:00
Rafael Espindola ae124da625 Force some values to be absolute and align based on the FDE pointers size. A small
step towards using .cfi_* on OS X.

llvm-svn: 130273
2011-04-27 01:43:49 +00:00
Rafael Espindola 3584ab6cc6 No relocation produces a SLEB or ULEB, make sure they are handled in MC.
llvm-svn: 130181
2011-04-26 02:17:58 +00:00
Sebastian Redl 1b86ea80bb Give MC/MCDisassembler/Disassembler.h a header guard.
llvm-svn: 130096
2011-04-24 15:46:56 +00:00
Jay Foad 1a180156b6 Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Chandler Carruth bab81b9797 Delete the other unused variable in this function. Sorry I missed this
the first time through.

llvm-svn: 129969
2011-04-22 01:29:18 +00:00
Chandler Carruth ea41470726 Remove an unused variable from a function. This is a likely cut-paste-o.
Silences GCC warning.

I wonder why Clang doesn't warn on this...

llvm-svn: 129968
2011-04-22 01:21:06 +00:00
Rafael Espindola 5395f44fe8 Compute the size of the FDE encoding instead of hard coding it. Update
X8664_ELFTargetObjectFile::getFDEEncoding to match reality.

llvm-svn: 129959
2011-04-22 00:08:43 +00:00
Rafael Espindola 6aea59268a Remove unused argument.
llvm-svn: 129955
2011-04-21 23:39:26 +00:00
Rafael Espindola ea61f22dd3 Don't pass address spaces to EmitULEB128IntValue.
llvm-svn: 129953
2011-04-21 23:26:40 +00:00
Rafael Espindola c3dc486752 Fix relative relocations. This is sufficient for running the rust testsuite with
MC :-)

llvm-svn: 129923
2011-04-21 18:36:50 +00:00
Rafael Espindola ed16477cb9 Behave like gnu as when a relocation crosses sections.
llvm-svn: 129850
2011-04-20 14:01:45 +00:00
Sean Callanan d897f39797 Made the MC disassembler check before accessing
MCInst operands for ARM.  This allows it to be
more tolerant of malformed MCInsts or incorrect
instruction metadata.

llvm-svn: 129840
2011-04-20 00:43:34 +00:00
Eli Friedman b2545fbc2a malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc.

(Revised version of r129688, with the necessary flush() call.)

llvm-svn: 129716
2011-04-18 20:54:46 +00:00
Devang Patel 17740e70d5 Reduce clutter in asm output. Do not emit source location as comment for each instruction.
llvm-svn: 129715
2011-04-18 20:26:49 +00:00
Eli Friedman 3f8ecf5cc5 Revert r129688; it's breaking buildbots.
llvm-svn: 129689
2011-04-18 05:54:54 +00:00
Eli Friedman 2dc287a147 More malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc.

llvm-svn: 129688
2011-04-18 05:38:58 +00:00
Eli Friedman 0e40208d7b Make the StringMaps attached to MCContext use the MCContext's allocator;
reduces the number of calls to malloc().

llvm-svn: 129687
2011-04-18 05:02:31 +00:00
Chris Lattner 0ab5e2cded Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Rafael Espindola 539d96f01d Be consistent about being virtual and returning void in the cfi methods.
Implement the ones that were missing in the asm streamer.

llvm-svn: 129413
2011-04-12 23:59:07 +00:00
Rafael Espindola fd794affe5 Remove LastOffset from the asm parser.
llvm-svn: 129378
2011-04-12 18:53:30 +00:00
Rafael Espindola 1ec0f46169 Fix the case of a .cfi_rel_offset before any .cfi_def_cfa_offset.
llvm-svn: 129362
2011-04-12 16:12:03 +00:00
Rafael Espindola 2e1c9d2188 Implement .cfi_same_value.
llvm-svn: 129361
2011-04-12 15:31:05 +00:00
Eric Christopher ffc0e1f6e6 Match case for invalid constant error messages and add a new
test for invalid hexadecimals.

llvm-svn: 129326
2011-04-12 00:18:03 +00:00
Eric Christopher 104af0619e To avoid printing out multiple error messages for cases like:
.long 80+08

go ahead and assume that if we've got an Error token that we handled it
already. Otherwise if it's a token we can't handle then go ahead and
return the default error.

llvm-svn: 129322
2011-04-12 00:03:13 +00:00
Eric Christopher 64749f2a89 Lex, and then fail on invalid constants.
Testcase forthcoming.

rdar://8490596

llvm-svn: 129309
2011-04-11 22:24:56 +00:00
Rafael Espindola 82065cb6cf Implement cfi_rel_offset
llvm-svn: 129306
2011-04-11 21:49:50 +00:00
Rafael Espindola ffd2e5163b implement .cfi_adjust_cfa_offset.
llvm-svn: 129296
2011-04-11 20:29:16 +00:00
Kevin Enderby 9377a52c12 Adding support for printing operands symbolically to llvm's public 'C'
disassembler API.  Hooked this up to the ARM target so such tools as Darwin's
otool(1) can now print things like branch targets for example this:
  blx _puts
instead of this:
  blx #-36
And even print the expression encoded in the Mach-O relocation entried for
things like this:
  movt r0, :upper16:((_foo-_bar)+1234)

llvm-svn: 129284
2011-04-11 18:08:50 +00:00
Benjamin Kramer 26e7768f38 Fix potential buffer overflow on win32.
llvm-svn: 129214
2011-04-09 14:06:12 +00:00
Benjamin Kramer 2b6c96b43d Don't store Twine temporaries, it's not safe.
And don't append the name over and over again in the loop.

llvm-svn: 129210
2011-04-09 11:26:27 +00:00
Sean Callanan 1426351c83 Redirected errors from the AsmParser to the proper
error stream, in cases where the AsmParser is
being invoked by EDDisassembler.  Before, they
were being sent to errs() because no error handler
was installed in the SourceMgr.

llvm-svn: 129177
2011-04-09 00:37:25 +00:00
Rafael Espindola b80875edee Micro optimization and improved similarity with gas' output:
When two section names share a suffix, reuse the entry in shstrtab.

llvm-svn: 129115
2011-04-07 23:21:52 +00:00
Rafael Espindola 88bc341061 Add support for .skip.
Patch by Roman Divacky.
Fixes PR9361.

llvm-svn: 129106
2011-04-07 20:26:23 +00:00
Sean Callanan 6c6be946fc Fixed a bug where missing EDInstInfo would cause
tokenization to crash and burn.

llvm-svn: 129051
2011-04-07 01:56:01 +00:00
Shantonu Sen e59f8ca49e An MCDisassembler has the option to not implement
getEDInfo(), in which case this code would dereference
NULL. EDInst can already handle NULL info, so avoid
the dereference and pass NULL through.

Reviewed by Sean Callanan

llvm-svn: 128904
2011-04-05 18:40:45 +00:00
Kevin Enderby 5bbe957155 Added support symbolic floating point constants in the MC assembler for Infinity
and Nans with the same strings as GAS supports.  rdar://8673024

llvm-svn: 128488
2011-03-29 21:11:52 +00:00
Francois Pichet 3cf622a832 Fix the MSVC build.
llvm-svn: 128441
2011-03-29 00:30:01 +00:00
Daniel Dunbar 4ee0d03274 MC: Add support for disabling "temporary label" behavior. Useful for debugging
on Darwin.

llvm-svn: 128430
2011-03-28 22:49:15 +00:00
Ted Kremenek 2d45693446 Unbreak CMake build.
llvm-svn: 128426
2011-03-28 20:43:53 +00:00
Kevin Enderby f3070dc40d Again adding a C API to the disassembler for use by such tools as Darwin's
otool(1), this time with the needed fix for case sensitive file systems :) .
This is a work in progress as the interface for producing symbolic operands is
not done.  But a hacked prototype using information from the object file's
relocation entiries and replacing immediate operands with MCExpr's has been
shown to work with no changes to the instrucion printer.  These APIs will be
moved into a dynamic library at some point.

llvm-svn: 128415
2011-03-28 18:25:07 +00:00
NAKAMURA Takumi af66980d8a Fix whitespace.
llvm-svn: 128370
2011-03-27 01:44:40 +00:00
Kevin Enderby d077a857cc Remove the files for r128308 as it is causing a buildbot failure.
llvm-svn: 128309
2011-03-26 00:23:05 +00:00
Kevin Enderby c8b4078654 Adding a C API to the disassembler for use by such tools as Darwin's otool(1).
This is a work in progress as the interface for producing symbolic operands is
not done.  But a hacked prototype using information from the object file's
relocation entiries and replacing immediate operands with MCExpr's has been
shown to work with no changes to the instrucion printer.  These APIs will be
moved into a dynamic library at some point.

llvm-svn: 128308
2011-03-26 00:06:33 +00:00
Daniel Dunbar 6f4c9425eb MC: Improve some diagnostics on uses of '.' pseudo-symbol.
llvm-svn: 128289
2011-03-25 17:47:17 +00:00
Daniel Dunbar 3f56104be1 Tidyness.
llvm-svn: 128288
2011-03-25 17:47:14 +00:00
Bruno Cardoso Lopes f170f8bff6 Add asm parsing support w/ testcases for strex/ldrex family of instructions
llvm-svn: 128236
2011-03-24 21:04:58 +00:00
Jim Grosbach a3df87fb01 Clean up assembly statement separator support.
The MC asm lexer wasn't honoring a non-default (anything but ';') statement
separator. Fix that, and generalize a bit to support multi-character
statement separators.

llvm-svn: 128227
2011-03-24 18:46:34 +00:00
Owen Anderson ab234158b8 Fix a bug introduced by my patch yesterday: BL is a 4-byte instructions like BLX, rather than a 2-byte instruction like B.
llvm-svn: 128169
2011-03-23 21:19:56 +00:00
Owen Anderson 6149a34102 RIT_ARM_ThumbBranch32Bit relocations are not used and should never be generated.
This fixes kimwitu++, bullet, and tramp3dv4 with the ARM integrated assembler.
Fixes <rdar://problem/9165738>.

llvm-svn: 128117
2011-03-22 22:52:54 +00:00
Owen Anderson 9746286bec Add support for Thumb interworking addresses for symbol offsets that get constant folded very early.
This fixes SPASS with -integrated-as.  <rdar://problem/9165399>

llvm-svn: 128037
2011-03-21 23:13:43 +00:00
Bill Wendling 00f0cddfd4 We need to pass the TargetMachine object to the InstPrinter if we are printing
the alias of an InstAlias instead of the thing being aliased. Because we need to
know the features that are valid for an InstAlias.

This is part of a work-in-progress.

llvm-svn: 127986
2011-03-21 04:13:46 +00:00
Rafael Espindola 1557fd6d39 Write the section table and the section data in the same order that
gun as does. This makes it a lot easier to compare the output of both
as the addresses are now a lot closer.

llvm-svn: 127972
2011-03-20 18:44:20 +00:00
Stuart Hastings 12d5312622 Reapply 127939 since Daniel fixed the breakage. <rdar://problem/9012638>
llvm-svn: 127944
2011-03-19 02:42:31 +00:00
Stuart Hastings 08b4daa191 Revert 127939. <rdar://problem/9012638>
llvm-svn: 127943
2011-03-19 02:33:56 +00:00
Stuart Hastings 83d4a28d1f Revise r126127 to address Daniel's comments. <rdar://problem/9012638>
llvm-svn: 127939
2011-03-19 01:32:01 +00:00
Daniel Dunbar f1d62cfc8f MC/Mach-O: Fix regression introduced in r126127, this assignment shouldn't have
been removed.

llvm-svn: 127812
2011-03-17 16:25:24 +00:00
Joerg Sonnenberger 07de07eeea Fix handling of @IDNTPOFF relocations, they need to get STT_TLS.
While here, add VK_ARM_TPOFF and VK_ARM_GOTTPOFF, too.

llvm-svn: 127780
2011-03-17 00:35:10 +00:00
Duncan Sands c2631d26c0 Silence compiler warning about case values not being in the enumerated type
MCFixupKind.  This is the same technique that is used elsewhere in MC.

llvm-svn: 127676
2011-03-15 08:54:51 +00:00
Sean Callanan 47f660aeaf Fixed the comparison operator for the enhanced
disassembler's disassembler map.

llvm-svn: 127527
2011-03-12 03:27:54 +00:00
Jan Sjödin 745fc89f62 Add constructors to MCElfStreamer and MCObjectStreamer to take an extra MCAssembler * argument.
llvm-svn: 127343
2011-03-09 17:33:05 +00:00
Jim Grosbach 14be61aeee Darwin 'as' silently ignores the '.ident' directive.
llvm-svn: 127258
2011-03-08 19:17:19 +00:00
Anton Korobeynikov e7410dd0d5 Preliminary support for ARM frame save directives emission via MI flags.
This is just very first approximation how the stuff should be done
(e.g. ARM-only for now). More to follow.

llvm-svn: 127101
2011-03-05 18:43:32 +00:00
Anton Korobeynikov a7ec2dcefd Some first rudimentary support for ARM EHABI: print exception table in "text mode".
llvm-svn: 127099
2011-03-05 18:43:15 +00:00
Joerg Sonnenberger 62f759791a Be nice to Xcore and the XMOS assembler and avoid quoting section names
that contain only letters, digits and the characters "_" and ".".

llvm-svn: 127028
2011-03-04 20:03:14 +00:00
Joerg Sonnenberger 852ab890b5 Bug#9033: For the ELF assembler output, always quote the section name.
llvm-svn: 126963
2011-03-03 22:31:08 +00:00
Jan Sjödin 771911e28b Split MCEELFStreamer and ELFObjectWriter into .h and .cpp files, so that other components can use them.
llvm-svn: 126942
2011-03-03 14:52:12 +00:00
Eli Friedman d92d17bf67 PR9352: Always emit a relocation for weak symbols. Not emitting relocations
for calls to weak symbols with a definition has the appearance of working
with LLVM-generated code because weak symbol definitions are put in their
own sections.

llvm-svn: 126933
2011-03-03 07:24:36 +00:00
Oscar Fuentes 98a3c80a3e Fixes warnings emitted by Visual Studio 2010 compiler.
Patch by Erik Olofsson!

llvm-svn: 126796
2011-03-01 23:11:57 +00:00
Jan Sjödin 30a52dec93 Make all static functions become static class methods. Move shared (duplicated) functions to new MCELF class.
llvm-svn: 126686
2011-02-28 21:45:04 +00:00
Cameron Zwarich fcf51fd298 Roll out r126425 and r126450 to see if it fixes the failures on the buildbots.
llvm-svn: 126488
2011-02-25 16:30:32 +00:00
Joerg Sonnenberger afb36fad99 Restore r125595 (reverted in r126336) with modifications:
Introduce a variable in the AsmParserExtension whether [] is valid in an
expression. If it is true, parse them like (). Enable this for ELF only.

llvm-svn: 126443
2011-02-24 21:59:22 +00:00
Devang Patel b037383a35 Enable DebugInfo support for COFF object files.
Patch by Nathan Jeffords!

llvm-svn: 126425
2011-02-24 21:04:00 +00:00
Benjamin Kramer c053644217 Plug some leaks in edis.
- Don't leak parsed operands during tokenization.
- Don't leak printed insts in llvm-mc.

llvm-svn: 126381
2011-02-24 11:03:19 +00:00
Jim Grosbach 0c03a3a146 Revert r125595, which is an X86-only undocumented assembly syntax extension
enabled for all targets. Non-X86 targets should not have this behavior
enabled by default.

Joerg, if you would like to resubmit with the behavior conditionalized to be
X86-ELF only, that's fine.

llvm-svn: 126336
2011-02-23 21:26:51 +00:00
Rafael Espindola 9e18e96264 Put in the symbol table symbols only used in a .globl statement.
Fixes PR9292.

llvm-svn: 126330
2011-02-23 20:22:07 +00:00
Sean Callanan 34770edf43 Fixed a bug in the enhanced disassembler that caused
it to ignore valid uses of FS and GS as additional
base registers in address computations.  Added a test
case for this.

llvm-svn: 126302
2011-02-23 03:31:28 +00:00
Stuart Hastings bf83659d11 Omit private_extern declarations of extern symbols; followup to
r124468.  Patch by Rafael Avila de Espindola!

llvm-svn: 126297
2011-02-23 02:27:05 +00:00
Joerg Sonnenberger 4f864d3111 Bug#9172: Don't use static in file scope, use an attribute on the
parser.

llvm-svn: 126225
2011-02-22 16:53:11 +00:00
Joerg Sonnenberger 37d5484d18 Handle FK_PCRel_1 and add a test case for this and FK_PCRel_4.
llvm-svn: 126157
2011-02-21 23:25:41 +00:00
Stuart Hastings d7927e0fcd End the line if we return early. Radar 9012638.
llvm-svn: 126141
2011-02-21 21:07:07 +00:00
Stuart Hastings b4863a41e9 Fix to correctly support attribute((section("__DATA, __common"))).
Radar 9012638.

llvm-svn: 126127
2011-02-21 17:27:17 +00:00
Joerg Sonnenberger eef2f9009d Use a vector of pairs to implement the section stack, not two
independent vectors.

llvm-svn: 126099
2011-02-21 01:07:42 +00:00
Rafael Espindola f849bf81bd Add some limited support for labels in org directives. Hopefully enough to fix
PR9245.

llvm-svn: 126091
2011-02-20 20:20:07 +00:00
Oscar Fuentes 5ed962656c Move library stuff out of the toplevel CMakeLists.txt file.
llvm-svn: 125968
2011-02-18 22:06:14 +00:00
Rafael Espindola 490d02a334 Gas is very inconsistent about when a relaxation/relocation is needed. Do
the right thing and stop trying to copy it. Fixes PR8944.

llvm-svn: 125648
2011-02-16 03:25:55 +00:00
Rafael Espindola 58ac6e1677 Add support for pushsection and popsection. Patch by Joerg Sonnenberger.
llvm-svn: 125629
2011-02-16 01:08:29 +00:00
Roman Divacky 4e0f4957bc Add support for parsing [expr].
This is submitted by Joerg Sonnenberger and fixes his PR8685.

llvm-svn: 125595
2011-02-15 20:43:39 +00:00
Rafael Espindola 70d8015063 Switch llvm to using comdats. For now always use groups with a single
section.

llvm-svn: 125526
2011-02-14 22:23:49 +00:00
Rafael Espindola 85bc995c5b Move broken HasCommonSymbols to ELFWriter.cpp.
llvm-svn: 125490
2011-02-14 16:51:08 +00:00
Jim Grosbach 01af6c4641 More whitespace cleanup...
llvm-svn: 125388
2011-02-11 19:05:56 +00:00
Shantonu Sen fd3e83953f Fix comparator used for looking up previously instantiated EDDisassemblers.
Now, Syntax is only used as a tie-breaker if the Arch
matches. Previously, a request for x86_64 disassembler followed by the
i386 disassembler in a single process would return the cached x86_64
disassembler. Fixes <rdar://problem/8958982>

llvm-svn: 125215
2011-02-09 21:03:19 +00:00
Benjamin Kramer 7b7caf51e9 Support for .ifdef / .ifndef in the assembler parser. Patch by Joerg Sonnenberger.
llvm-svn: 125120
2011-02-08 22:29:56 +00:00
Jason W Kim 202630c6ee Teach ARM/MC/ELF about gcc compatible reloc output to get past odd linkage
failures with relocations.

The code committed is a first cut at compatibility for emitted relocations in
ELF .o.

Why do this? because existing ARM tools like emitting relocs symbols as
explicit relocations, not as section-offset relocs.

Result is that with these changes,
1) relocs are now substantially identical what to gcc outputs.
2) larger apps (including many spec2k tests) compile, cross-link, and pass

Added reminder fixme to tests for future conversion to .s form.

llvm-svn: 124996
2011-02-07 01:11:15 +00:00
Jason W Kim 4761fba833 Teach ARM/MC/ELF about EF_ARM_EABI_VERSION. The magic number is set to
5 to match the current doc.
Added FIXME reminder Make it really configurable later.

llvm-svn: 124899
2011-02-04 21:41:11 +00:00
Jason W Kim d2e2f56c36 Teach ARM/MC/ELF to handle R_ARM_JUMP24 relocation type for conditional jumps.
(yes, this is different from R_ARM_CALL)

- Adds a new method getARMBranchTargetOpValue() which handles the
  necessary distinction between the conditional and unconditional br/bl
  needed for ARM/ELF

At least for ARM mode, the needed fixup for conditional versus unconditional
br/bl is identical, but the ARM docs and existing ARM tools expect this
reloc type...

Added a few FIXME's for future naming fixups in ARMInstrInfo.td

llvm-svn: 124895
2011-02-04 19:47:15 +00:00
Bob Wilson 813bdf6e58 Do not sign extend floating-point values in the asm parser.
llvm-svn: 124831
2011-02-03 23:17:47 +00:00
Evan Cheng dfc85ed01e Fix bogus assert condition noticed by Csaba Raduly.
llvm-svn: 124645
2011-02-01 01:50:49 +00:00
Roman Divacky 9a58919c8e Enumerate .code16/32/64 instead of checking .code prefix. This
unbreaks some ARM tests.

llvm-svn: 124608
2011-01-31 21:19:43 +00:00
Roman Divacky bd59dff739 Error on all .code* directives instead of just .code16 as they
all lead to a silent miscompilation of code.

llvm-svn: 124603
2011-01-31 20:56:49 +00:00
Roman Divacky cd9ae95ae7 Error on .code16 instead of producing wrong (32bit) code.
llvm-svn: 124498
2011-01-28 19:29:48 +00:00
Roman Divacky 7e9e290952 Add support for parsing .float
llvm-svn: 124485
2011-01-28 14:20:32 +00:00
Nico Weber 4ada0d9164 PR8951: Support for .equiv in integrated assembler, patch by Jörg Sonnenberger!
llvm-svn: 124467
2011-01-28 03:04:41 +00:00
Roman Divacky ed5efb4053 Add support for specifying register name in cfi-register/offset/def
as well as register number.

llvm-svn: 124379
2011-01-27 17:16:37 +00:00
Bill Wendling cdbf17b179 Add support for parsing a Real value. It stores the Real value as its binary
encoding. It's up to the individual back-ends to convert it to their preferred
representation when printing.

llvm-svn: 124229
2011-01-25 21:26:41 +00:00
Rafael Espindola 689939e648 Handle strings in section names the same way as gas:
* If the name is a single string, we remove the quotes
* If the name starts without a quote, we include any quotes in the name

llvm-svn: 124127
2011-01-24 18:02:54 +00:00
Rafael Espindola b3eca9bb71 Add support for the --noexecstack option.
llvm-svn: 124077
2011-01-23 17:55:27 +00:00
Rafael Espindola 8bac423ddb Add support for lowercase variants.
llvm-svn: 124071
2011-01-23 16:11:25 +00:00
Rafael Espindola 4b7b7fba38 Delay the creation of eh_frame so that the user can change the defaults.
Add support for SHT_X86_64_UNWIND.

llvm-svn: 124059
2011-01-23 05:43:40 +00:00
Rafael Espindola 0e7e34e476 Remove more duplicated code.
llvm-svn: 124056
2011-01-23 04:43:11 +00:00
Rafael Espindola aea4958ea6 Remove duplicated code.
llvm-svn: 124054
2011-01-23 04:28:49 +00:00
Jim Grosbach 493c0fbde8 Make sure to propogate the error code when we fail to parse a modifier.
llvm-svn: 123857
2011-01-19 23:06:07 +00:00
Anton Korobeynikov e2bea1c82e Use common style for .cfi directives
llvm-svn: 123472
2011-01-14 21:57:39 +00:00
Evan Cheng d4a5c05c97 Completed :lower16: / :upper16: support for movw / movt pairs on Darwin.
- Fixed :upper16: fix up routine. It should be shifting down the top 16 bits first.
- Added support for Thumb2 :lower16: and :upper16: fix up.
- Added :upper16: and :lower16: relocation support to mach-o object writer.

llvm-svn: 123424
2011-01-14 02:38:49 +00:00
Evan Cheng 52899a9c34 Add comment about Thumb2 fixup comments being completely bogus.
llvm-svn: 123411
2011-01-13 23:27:39 +00:00
Evan Cheng 0447d30939 Relax an assertion. On archs like ARM, an immediate field may be scattered. So it's possible for some bits of every 8 bits to be encoded already, and the rest still needs to be fixed up.
llvm-svn: 123403
2011-01-13 21:45:26 +00:00
Evan Cheng 965b3c7323 Model :upper16: and :lower16: as ARM specific MCTargetExpr. This is a step
in the right direction. It eliminated some hacks and will unblock codegen
work. But it's far from being done. It doesn't reject illegal expressions,
e.g. (FOO - :lower16:BAR). It also doesn't work in Thumb2 mode at all.

llvm-svn: 123369
2011-01-13 07:58:56 +00:00
Jason W Kim 39e36e7ab4 Style clean up - break up the breaks.
llvm-svn: 123347
2011-01-13 00:07:51 +00:00
Jason W Kim 9c5b65d289 1. Support ELF pcrel relocations for movw/movt:
R_ARM_MOVT_PREL and R_ARM_MOVW_PREL_NC.
2. Fix minor bug in ARMAsmPrinter - treat bitfield flag as a bitfield, not an enum.
3. Add support for 3 new elf section types (no-ops)

llvm-svn: 123294
2011-01-12 00:19:25 +00:00
Anton Korobeynikov 2f93128109 Rename TargetFrameInfo into TargetFrameLowering. Also, put couple of FIXMEs and fixes here and there.
llvm-svn: 123170
2011-01-10 12:39:04 +00:00
Rafael Espindola 3686473578 Fix PR8878.
llvm-svn: 122658
2011-01-01 19:05:35 +00:00
Benjamin Kramer 570dd787a6 Make a bunch of symbols internal.
llvm-svn: 122642
2010-12-30 22:34:44 +00:00
Daniel Dunbar ab14a6f174 MC/Mach-O/Thumb: Set the thumb bit in the symbol table.
llvm-svn: 122630
2010-12-29 14:14:06 +00:00
Rafael Espindola 46a5b05207 Correctly encode pcrel|indirect.
llvm-svn: 122624
2010-12-29 04:31:26 +00:00
Rafael Espindola 2ae93b2c9c Remove second return.
llvm-svn: 122616
2010-12-29 02:42:33 +00:00
Rafael Espindola 563301dfdb Fix bug when trying to output uint16_t or uint32_t.
llvm-svn: 122615
2010-12-29 02:30:49 +00:00
Rafael Espindola 290d71671e Implement cfi_def_cfa. Also don't convert to dwarf reg numbers twice. Looks
like 6 is a fixed point of that and so the previous tests were OK :-)

llvm-svn: 122614
2010-12-29 01:42:56 +00:00
Rafael Espindola 426e68f793 Implement cfi_def_cfa_register.
llvm-svn: 122612
2010-12-29 00:26:06 +00:00
Rafael Espindola 86d347dd31 Initial .cfi_offset implementation.
llvm-svn: 122611
2010-12-29 00:09:59 +00:00
Rafael Espindola 6bbfb6c06c Don't produce a "DW_CFA_advance_loc 0".
llvm-svn: 122609
2010-12-28 23:38:03 +00:00
Rafael Espindola 85d91982ca Implement .cfi_remember_state and .cfi_restore_state.
llvm-svn: 122602
2010-12-28 18:36:23 +00:00
Benjamin Kramer b6d52b8b64 Cast away "comparison between signed and unsigned integer" warnings.
llvm-svn: 122598
2010-12-28 13:52:52 +00:00
Duncan Sands 3784c5ea3c Fix warning about size potentially being used uninitialized
when doing a release build.

llvm-svn: 122594
2010-12-28 10:02:42 +00:00
Rafael Espindola 736a35d9ab Relax address updates in the eh_frame section.
llvm-svn: 122591
2010-12-28 05:39:27 +00:00
Rafael Espindola a75b87b55a Start adding basic support for emitting the call frame instructions.
llvm-svn: 122590
2010-12-28 04:15:37 +00:00
Rafael Espindola 1de2dd0e5e Add support for .cfi_lsda.
llvm-svn: 122584
2010-12-27 15:56:22 +00:00
Daniel Dunbar a895c69431 MC/Mach-O/Thumb: Select appropriate relocation types for Thumb.
llvm-svn: 122583
2010-12-27 14:49:49 +00:00
Rafael Espindola 8fc59a682f Handle reloc_riprel_4byte_movq_load. Should make the bots happy.
llvm-svn: 122579
2010-12-27 02:03:24 +00:00
Rafael Espindola 2ac8355ecd Add support for the same encodings of the personality function that gnu as
supports.

llvm-svn: 122577
2010-12-27 00:36:05 +00:00
Rafael Espindola 54462cd730 Fix .cfi_personality on 32 bit systems.
llvm-svn: 122570
2010-12-26 22:47:37 +00:00
Rafael Espindola 9ae2d05d45 Add support for @note. Patch by Jörg Sonnenberger.
llvm-svn: 122568
2010-12-26 21:30:59 +00:00
Rafael Espindola 9141b611ad Add basic support for .cfi_personality.
llvm-svn: 122566
2010-12-26 20:20:31 +00:00
Chris Lattner 03a102bff3 Generalize a previous change, fixing PR8855 - an valid large immediate
rejected by the mc assembler.

llvm-svn: 122557
2010-12-25 21:36:35 +00:00