Commit Graph

736 Commits

Author SHA1 Message Date
Michael J. Spencer
28ca86aa19 MC-COFF: Fix .bss section size. Fixes PR8335. Patch by NAKAMUTA Takumi!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116155 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-09 16:04:45 +00:00
Michael J. Spencer
192d136750 MC-COFF: Implement InitSections. Fixes PR8335.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116151 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-09 15:44:27 +00:00
Michael J. Spencer
7d4900416a MC-COFF: Add COFFAsmParser. Completes PR8343.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-09 11:01:07 +00:00
Michael J. Spencer
c0c8df3cea Fix Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116149 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-09 11:00:50 +00:00
Michael J. Spencer
d47f4a9c98 MC-COFF: Assert on non-coff sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116148 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-09 11:00:37 +00:00
Michael J. Spencer
e90ea139f4 MC: Move ParseDirectiveELFType into ELFAsmParser. COFF uses .type for something else.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116142 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-09 03:47:55 +00:00
Michael J. Spencer
b225adee29 MC-COFF: Handle relaxation in COFF better. Fixes PR8321.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116013 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-07 23:55:40 +00:00
NAKAMURA Takumi
86c3647ddf Minor cosmetic change: fix DOSish \r\n.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115910 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-07 07:21:04 +00:00
Michael J. Spencer
b5814a3c15 MC-COFF: Fix symbol aliases. Fixes PR8251.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115909 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-07 06:29:33 +00:00
Rafael Espindola
d8e0bfe07a Another case of 256 sections not being enough :-)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115858 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 22:28:19 +00:00
Rafael Espindola
152c1061e0 Get binding and visibility info from the the alias, but Type from the symbol
being aliased.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 21:02:29 +00:00
Michael J. Spencer
345ed9806a MC: Add missing forward in MCLoggingStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115830 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 20:36:47 +00:00
Rafael Espindola
153666c038 If a symbol is global, reloc against it even if it is in a mergeable section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115817 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 19:27:21 +00:00
Rafael Espindola
3223f19ff0 Make sure weak symbols are listed after the local ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 16:47:31 +00:00
Rafael Espindola
8cecf253e4 Correctly handle GOTPCREL relocations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115793 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 16:23:36 +00:00
Rafael Espindola
3729d0052b Use a relocation against the symbol if it is a PLT and the symbol is in another
section. Common because of linkonce sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115718 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 23:57:26 +00:00
Rafael Espindola
01f9ea35a7 Implement more alias cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115699 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 22:26:43 +00:00
Rafael Espindola
f5c347dfc2 256 sections should be enough for anyone...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115687 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 21:20:07 +00:00
Rafael Espindola
62fed8bd38 Don't crash in a strange .size directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115684 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 21:02:45 +00:00
Michael J. Spencer
ea1104a4c3 Fix Punctuation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115657 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 19:48:12 +00:00
Michael J. Spencer
eb6e77f8cc MC-COFF: Fix (PR8278) temporary symbol relocations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115656 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 19:48:03 +00:00
Rafael Espindola
e452b17130 Add support for a fill value in the .zero directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115655 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 19:42:57 +00:00
Rafael Espindola
737cd213e3 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115643 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 18:01:23 +00:00
Rafael Espindola
5c77c16f31 Produce a undefined reference to _GLOBAL_OFFSET_TABLE_ when needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115623 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 15:48:37 +00:00
Rafael Espindola
8f413fa9c0 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115619 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 15:11:03 +00:00
Kevin Enderby
3f55c24df9 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115551 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 20:17:24 +00:00
Rafael Espindola
607d1f6d32 Implement ELF::R_X86_64_GOTPCREL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115547 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 19:51:39 +00:00
Rafael Espindola
cebdc01d66 Move isFixupKindX86PCRel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115545 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 19:46:28 +00:00
Rafael Espindola
92bf6684f6 Produce a R_X86_64_PLT32 when needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 19:04:13 +00:00
Rafael Espindola
28f9ac8101 Produce a R_X86_64_GOT32 when needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115537 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 18:44:25 +00:00
Jan Wen Voung
083cf1574f 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115523 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 17:32:41 +00:00
Rafael Espindola
55fb102130 Include the section address in the computation of the relocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115509 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 15:59:01 +00:00
Rafael Espindola
01263d35d4 Correctly compute the relocation when it is not in the first fragment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115506 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-04 15:28:43 +00:00
Rafael Espindola
9d8b7555cd Implement a very basic PIC case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115454 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-03 00:46:57 +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
Rafael Espindola
7eae36b38b 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115194 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 20:18:35 +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
Kevin Enderby
b5a3ec17a4 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115155 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 16:42:21 +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
Jan Wen Voung
186e7a0fb1 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115141 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 05:59:22 +00:00
Rafael Espindola
a8c02c3bdd 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 03:11:42 +00:00
Jason W Kim
afd1cc2578 Tiny patch for proof-of-concept cleanup of ARMAsmPrinter::EmitStartOfAsmFile()
Small test for sanity check of resulting ARM .s file.
Tested against -r115129.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 02:45:56 +00:00
Jan Wen Voung
12ad94e03c Have ELFAsmParser.cpp use the already parsed "Size" (entry size) when
constructing a section. Test for a few cases also included.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115132 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 02:41:46 +00:00
Rafael Espindola
7070387f08 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115131 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 02:22:20 +00:00
Jan Wen Voung
a854a4bbc8 Test commit - Deleted some whitespace at the end of a line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115122 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 01:09:20 +00:00
Rafael Espindola
9e3922e949 Move "local commons" to the end of .bss to match the gnu as behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115037 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-29 14:52:01 +00:00
Michael J. Spencer
81100d0608 MC-COFF: Fix symbol storage class for globals
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115020 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-29 03:13:41 +00:00
Chris Lattner
7036f8be4d 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115014 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-29 01:42:58 +00:00
Rafael Espindola
53725bc57a On elf, undefined symbols can start with .L.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114958 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28 16:19:11 +00:00
Rafael Espindola
c3c413f631 Write relocations in the end of the file. This matches what gas does and
makes files easier to diff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114898 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-27 22:04:54 +00:00