Commit Graph

736 Commits

Author SHA1 Message Date
Michael J. Spencer a6a984bd96 MC-COFF: Fix .bss section size. Fixes PR8335. Patch by NAKAMUTA Takumi!
llvm-svn: 116155
2010-10-09 16:04:45 +00:00
Michael J. Spencer 86bbd71088 MC-COFF: Implement InitSections. Fixes PR8335.
llvm-svn: 116151
2010-10-09 15:44:27 +00:00
Michael J. Spencer c8dbdfd4ba MC-COFF: Add COFFAsmParser. Completes PR8343.
llvm-svn: 116150
2010-10-09 11:01:07 +00:00
Michael J. Spencer 530ce85b3e Fix Whitespace.
llvm-svn: 116149
2010-10-09 11:00:50 +00:00
Michael J. Spencer be52c62a6d MC-COFF: Assert on non-coff sections.
llvm-svn: 116148
2010-10-09 11:00:37 +00:00
Michael J. Spencer 3d89823102 MC: Move ParseDirectiveELFType into ELFAsmParser. COFF uses .type for something else.
llvm-svn: 116142
2010-10-09 03:47:55 +00:00
Michael J. Spencer aaf4643a31 MC-COFF: Handle relaxation in COFF better. Fixes PR8321.
llvm-svn: 116013
2010-10-07 23:55:40 +00:00
NAKAMURA Takumi 87002b592e Minor cosmetic change: fix DOSish \r\n.
llvm-svn: 115910
2010-10-07 07:21:04 +00:00
Michael J. Spencer 1666b61357 MC-COFF: Fix symbol aliases. Fixes PR8251.
llvm-svn: 115909
2010-10-07 06:29:33 +00:00
Rafael Espindola 883936ce0b Another case of 256 sections not being enough :-)
llvm-svn: 115858
2010-10-06 22:28:19 +00:00
Rafael Espindola 5f2d6a5cd9 Get binding and visibility info from the the alias, but Type from the symbol
being aliased.

llvm-svn: 115836
2010-10-06 21:02:29 +00:00
Michael J. Spencer e535b01a74 MC: Add missing forward in MCLoggingStreamer.
llvm-svn: 115830
2010-10-06 20:36:47 +00:00
Rafael Espindola d444577382 If a symbol is global, reloc against it even if it is in a mergeable section.
llvm-svn: 115817
2010-10-06 19:27:21 +00:00
Rafael Espindola 83b2a3337f Make sure weak symbols are listed after the local ones.
llvm-svn: 115795
2010-10-06 16:47:31 +00:00
Rafael Espindola 8f3d2c9058 Correctly handle GOTPCREL relocations.
llvm-svn: 115793
2010-10-06 16:23:36 +00:00
Rafael Espindola d7565c3a06 Use a relocation against the symbol if it is a PLT and the symbol is in another
section. Common because of linkonce sections.

llvm-svn: 115718
2010-10-05 23:57:26 +00:00
Rafael Espindola 0ad137e98e Implement more alias cases.
llvm-svn: 115699
2010-10-05 22:26:43 +00:00
Rafael Espindola 3844da781f 256 sections should be enough for anyone...
llvm-svn: 115687
2010-10-05 21:20:07 +00:00
Rafael Espindola c58a37ea51 Don't crash in a strange .size directive.
llvm-svn: 115684
2010-10-05 21:02:45 +00:00
Michael J. Spencer a65d17a5ca Fix Punctuation.
llvm-svn: 115657
2010-10-05 19:48:12 +00:00
Michael J. Spencer a3b34ed2df MC-COFF: Fix (PR8278) temporary symbol relocations.
llvm-svn: 115656
2010-10-05 19:48:03 +00:00
Rafael Espindola b91bac6c96 Add support for a fill value in the .zero directive.
llvm-svn: 115655
2010-10-05 19:42:57 +00:00
Rafael Espindola b1d0789357 Implement a simple alias case and refactor the code a bit so that the
isInSymtab and isLocal logic in the two loops don't get easily out of sync.

llvm-svn: 115643
2010-10-05 18:01:23 +00:00
Rafael Espindola d03e81dba8 Produce a undefined reference to _GLOBAL_OFFSET_TABLE_ when needed.
llvm-svn: 115623
2010-10-05 15:48:37 +00:00
Rafael Espindola bce26a1ee0 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 a68d004d88 Incorporate suggestions by Daniel Dunbar after his review. Thanks Daniel!
1) Changed ValidateDwarfFileNumber() to isValidDwarfFileNumber() to be better
   named.  Since it is just a predicate and isn't actually changing any state.

2) Added a missing return in the comments for setCurrentDwarfLoc() in 
   include/llvm/MC/MCContext.h for fix formatting.

3) Changed clearDwarfLocSeen() to ClearDwarfLocSeen() since it does change
   state.

4) Simplified the last test in isValidDwarfFileNumber() to just a one line
   boolean test of MCDwarfFiles[FileNumber] != 0 for the final return statement.

llvm-svn: 115551
2010-10-04 20:17:24 +00:00
Rafael Espindola fd1fff8b19 Implement ELF::R_X86_64_GOTPCREL.
llvm-svn: 115547
2010-10-04 19:51:39 +00:00
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
Jan Wen Voung 87f77b5f9a Add hook in MCSection to decide when to use "optimized nops", for each
section kind. Previously, optimized nops were only used for MachO.
Also added tests for ELF and COFF.

llvm-svn: 115523
2010-10-04 17:32:41 +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
Kevin Enderby a8d176866d 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 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
Kevin Enderby e46564a4a8 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.

llvm-svn: 115157
2010-09-30 16:52:03 +00:00
Kevin Enderby dce906c77f Changes EvaluateAsAbsolute() to return the "current value" of the expression
if we are given a Layout object, even in cases when the value is not fixed.
This will be needed by the final patch for the dwarf .loc support to size a
new MCDwarf fragment needed to build and emit dwarf line number tables.

llvm-svn: 115155
2010-09-30 16:42:21 +00:00
Chandler Carruth f44d350614 Silence a GCC warning about not handling all flags in this switch, we
specifically assert on unexpected flags.

llvm-svn: 115143
2010-09-30 10:59:51 +00:00
Jan Wen Voung efbdbe5565 Move logic of determining ELF entsize from the .s printer to initialization
time. That way, the EntrySize field is initialized for other code paths, 
namely, the .ll -> .o code path.

llvm-svn: 115141
2010-09-30 05:59:22 +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
Jason W Kim 645f6c2bef Tiny patch for proof-of-concept cleanup of ARMAsmPrinter::EmitStartOfAsmFile()
Small test for sanity check of resulting ARM .s file.
Tested against -r115129.

llvm-svn: 115133
2010-09-30 02:45:56 +00:00
Jan Wen Voung b96b2d8e4d Have ELFAsmParser.cpp use the already parsed "Size" (entry size) when
constructing a section. Test for a few cases also included.

llvm-svn: 115132
2010-09-30 02:41:46 +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
Jan Wen Voung c768287968 Test commit - Deleted some whitespace at the end of a line.
llvm-svn: 115122
2010-09-30 01:09:20 +00:00
Rafael Espindola 53f0bf194a Move "local commons" to the end of .bss to match the gnu as behavior.
llvm-svn: 115037
2010-09-29 14:52:01 +00:00
Michael J. Spencer 86a6222469 MC-COFF: Fix symbol storage class for globals
llvm-svn: 115020
2010-09-29 03:13:41 +00:00
Chris Lattner b44fd24fc1 change the protocol TargetAsmPArser::MatchInstruction method to take an
MCStreamer to emit into instead of an MCInst to fill in.  This allows the
matcher extra flexibility and is more convenient.

llvm-svn: 115014
2010-09-29 01:42:58 +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