Peter Collingbourne
2f495b93ee
Add support for subsections to the ELF assembler. Fixes PR8717.
...
Differential Revision: http://llvm-reviews.chandlerc.com/D598
llvm-svn: 179725
2013-04-17 21:18:16 +00:00
Nico Rieck
ba848e3bca
Replace coff-/elf-dump with llvm-readobj
...
llvm-svn: 179361
2013-04-12 04:06:46 +00:00
Peter Collingbourne
adac407ed9
Use a scheme closer to that of GNU as when deciding the type of a
...
symbol with multiple .type declarations.
Differential Revision: http://llvm-reviews.chandlerc.com/D607
llvm-svn: 179184
2013-04-10 16:52:15 +00:00
Eric Christopher
9cad53cfec
Implements low-level object file format specific output for COFF and
...
ELF with support for:
- File headers
- Section headers + data
- Relocations
- Symbols
- Unwind data (only COFF/Win64)
The output format follows a few rules:
- Values are almost always output one per line (as elf-dump/coff-dump already do). - Many values are translated to something readable (like enum names), with the raw value in parentheses.
- Hex numbers are output in uppercase, prefixed with "0x".
- Flags are sorted alphabetically.
- Lists and groups are always delimited.
Example output:
---------- snip ----------
Sections [
Section {
Index: 1
Name: .text (5)
Type: SHT_PROGBITS (0x1)
Flags [ (0x6)
SHF_ALLOC (0x2)
SHF_EXECINSTR (0x4)
]
Address: 0x0
Offset: 0x40
Size: 33
Link: 0
Info: 0
AddressAlignment: 16
EntrySize: 0
Relocations [
0x6 R_386_32 .rodata.str1.1 0x0
0xB R_386_PC32 puts 0x0
0x12 R_386_32 .rodata.str1.1 0x0
0x17 R_386_PC32 puts 0x0
]
SectionData (
0000: 83EC04C7 04240000 0000E8FC FFFFFFC7 |.....$..........|
0010: 04240600 0000E8FC FFFFFF31 C083C404 |.$.........1....|
0020: C3 |.|
)
}
]
---------- snip ----------
Relocations and symbols can be output standalone or together with the section header as displayed in the example.
This feature set supports all tests in test/MC/COFF and test/MC/ELF (and I suspect all additional tests using elf-dump), making elf-dump and coff-dump deprecated.
Patch by Nico Rieck!
llvm-svn: 178679
2013-04-03 18:31:38 +00:00
Rafael Espindola
ddbf4f47dc
Move test since it depends on the X86 backend.
...
llvm-svn: 178249
2013-03-28 17:01:28 +00:00
Michael Gottesman
f23bb4e558
Revert "Updated ELF relocation test for .eh_frame section"
...
This reverts commit c8d65364223a04b179958a50a4bf0f89b21dd7d2.
This broke a bunch of the buildbots.
llvm-svn: 178222
2013-03-28 05:14:26 +00:00
Jack Carter
ccc266559f
Updated ELF relocation test for .eh_frame section
...
Made sure we were looking a correct section
Added Mips32/64 as an extra check
Updated llvm-objdump to generate symbolic info for Mips relocations
llvm-svn: 178190
2013-03-27 22:58:49 +00:00
Rafael Espindola
ef9d3494b2
Fix the FDE encoding to be relative on ELF.
...
This is a very late complement to r130637 which fixed this on x86_64. Fixes
pr15448.
Since it looks like that every elf architecture uses this encoding when using
cfi, make it the default for elf. Just exclude mips64el. It has a lovely
.ll -> .o test (ef_frame.ll) that tests that nothing changes in the binary
content of the .eh_frame produced by llc. Oblige it.
llvm-svn: 177141
2013-03-15 05:51:57 +00:00
Nick Lewycky
c1f9694d05
We need a shndx if the number of sections breaks SHN_LORESERVE. This condition
...
for choosing to emit a shndx was simply testing the wrong variable.
llvm-svn: 176762
2013-03-09 09:31:44 +00:00
Eli Bendersky
10ab5e72e1
Rewrite a test to check actual output rather than intermediate implementation
...
detail.
The was this test was written, it was relying on an implementation detail
(fixups) and hence was very brittle (relying, among other things, on the
exact ordering of statistics printed by MC).
The test was rewritten to check a more observable output difference. While it
doesn't cover 100% of the things the original test covered, it's a good
practice to write regression tests this way. If we want to check that
internal details and invariants hold, such tests should be expressed as unit
tests.
llvm-svn: 176377
2013-03-01 20:54:00 +00:00
Eli Bendersky
e6abe83258
Now that llvm-dwarfdump supports flags to specify which DWARF section to dump,
...
use them in tests that run llvm-dwarfdump. This is in order to make tests as
specific as possible.
llvm-svn: 173498
2013-01-25 21:44:53 +00:00
NAKAMURA Takumi
ad0c80b8e6
llvm/test/MC/ELF/comp-dir.s: Appease MSYS Bash.
...
llvm-svn: 170410
2012-12-18 05:08:12 +00:00
Chandler Carruth
d75be9b4fb
Add a triple to this test -- it has to be an ELF platform...
...
llvm-svn: 170374
2012-12-17 21:44:50 +00:00
Chandler Carruth
10700aad85
Prepare LLVM to fix PR14625, exposing a hook in MCContext to manage the
...
compilation directory.
This defaults to the current working directory, just as it always has,
but now an assembler can choose to override it with a custom directory.
I've taught llvm-mc about this option and added a test case.
llvm-svn: 170371
2012-12-17 21:32:42 +00:00
Eli Bendersky
7352e4ffcb
Add a test for explicitly exercising the mc-relax-all flag.
...
llvm-svn: 169764
2012-12-10 20:36:01 +00:00
Eli Bendersky
2ccd044c22
Add separate statistics for Data and Inst fragments emitted during relaxation.
...
Also fixes a test that was overly-sensitive to the exact order of statistics
emitted.
llvm-svn: 169619
2012-12-07 17:59:21 +00:00
Rafael Espindola
cdb9a538d6
Add support for .cfi_register now that it is easy to extent the representation
...
to support it. Original patch with the parsing and plumbing by the PaX team and
Roman Divacky. I added the bits in MCDwarf.cpp and the test.
llvm-svn: 168565
2012-11-25 15:14:49 +00:00
Rafael Espindola
9bb247813a
Implement .cfi_undefined. Based on a patch from PaX team, updated by
...
Roman Divacky. I just added the testcase.
llvm-svn: 168520
2012-11-23 16:59:41 +00:00
Alexey Samsonov
00fd5257a2
Emit relocations from .debug_aranges to .debug_info for asm files
...
llvm-svn: 167926
2012-11-14 09:55:38 +00:00
Benjamin Kramer
47f9ec92cb
MC: Overhaul handling of .lcomm
...
- Darwin lied about not supporting .lcomm and turned it into zerofill in the
asm parser. Push the zerofill-conversion down into macho-specific code.
- This makes the tri-state LCOMMType enum superfluous, there are no targets
without .lcomm.
- Do proper error reporting when trying to use .lcomm with alignment on a target
that doesn't support it.
- .comm and .lcomm alignment was parsed in bytes on COFF, should be power of 2.
- Fixes PR13755 (.lcomm crashes on ELF).
llvm-svn: 163395
2012-09-07 17:25:13 +00:00
Benjamin Kramer
e3d658bb6c
PR13754: llvm-mc/x86 crashes on .cfi directives without the % prefix for registers.
...
gas accepts this and it seems to be common enough to be worth supporting. This
doesn't affect the parsing of reg operands outside of .cfi directives.
llvm-svn: 163390
2012-09-07 14:51:35 +00:00
Nick Lewycky
1dcfe449ef
Give this test an explicit triple.
...
llvm-svn: 161740
2012-08-12 08:21:27 +00:00
Nick Lewycky
333449cd65
When emitting the PC range in an FDE, use the same data encoding for both ends
...
of the range. Fixes PR13581!
llvm-svn: 161739
2012-08-12 08:09:45 +00:00
Benjamin Kramer
6bee7f750d
ELF: Add support for the asm .version directive.
...
llvm-svn: 156712
2012-05-12 14:30:47 +00:00
Eli Bendersky
f33086052d
Continue cleanup of LIT, getting rid of the remaining artifacts from dejagnu
...
* Removed test/lib/llvm.exp - it is no longer needed
* Deleted the dg.exp reading code from test/lit.cfg. There are no dg.exp files
left in the test suite so this code is no longer required. test/lit.cfg is
now much shorter and clearer
* Removed a lot of duplicate code in lit.local.cfg files that need access to
the root configuration, by adding a "root" attribute to the TestingConfig
object. This attribute is dynamically computed to provide the same
information as was previously provided by the custom getRoot functions.
* Documented the config.root attribute in docs/CommandGuide/lit.pod
llvm-svn: 153408
2012-03-25 09:02:19 +00:00
David Meyer
1df4b84db4
In the ObjectFile interface, replace isInternal(), isAbsolute(), isGlobal(), and isWeak(), with a bitset of flags.
...
llvm-svn: 151670
2012-02-28 23:47:53 +00:00
Rafael Espindola
c22c85c29c
On ELF, create relocations to the abbreviation and line sections when producing
...
debug info for assembly files. We were already doing the right thing when
producing debug info for C/C++.
ELF linkers don't know dwarf, so they depend on these relocations to produce
valid dwarf output.
llvm-svn: 151655
2012-02-28 21:13:05 +00:00
Eli Bendersky
924f9a671d
Replace all instances of dg.exp file with lit.local.cfg, since all tests are run with LIT now and now Dejagnu. dg.exp is no longer needed.
...
Patch reviewed by Daniel Dunbar. It will be followed by additional cleanup patches.
llvm-svn: 150664
2012-02-16 06:28:33 +00:00
David Meyer
44ec69efe0
For ELF, also call fixSymbolsInTLSFixups() on expressions passed to EmitValue (literal values). Previously only called on expressions in instructions. New test cases added to tls.s, tls-i386.s. Resolves PR11981.
...
llvm-svn: 150582
2012-02-15 15:09:06 +00:00
Rafael Espindola
3c47e37387
Add support for .cfi_signal_frame. Fixes pr11762.
...
llvm-svn: 148733
2012-01-23 21:51:52 +00:00
Rafael Espindola
4ea99816ef
Implement cfi_restore. Patch by Brian Anderson!
...
llvm-svn: 147356
2011-12-29 21:43:03 +00:00
Rafael Espindola
ef4aa35164
Implement .cfi_escape. Patch by Brian Anderson!
...
llvm-svn: 147352
2011-12-29 20:24:47 +00:00
Roman Divacky
735cb8bcdc
Add support for gnu_indirect_function.
...
llvm-svn: 146377
2011-12-12 17:34:04 +00:00
Rafael Espindola
c7f355b8e1
Handle expressions of the form _GLOBAL_OFFSET_TABLE_-symbol the same way gas
...
does. The _GLOBAL_OFFSET_TABLE_ is still magical in that we get a R_386_GOTPC,
but it doesn't change the immediate in the same way as when the expression
has no right hand side symbol.
llvm-svn: 146311
2011-12-10 02:28:43 +00:00
Rafael Espindola
7e0a793183
Handle reloc_signed_4byte in here. Not doing so was a regression from my
...
previous commit. It is strange that we see it in 32 bits. We already
have a fixme about it.
llvm-svn: 146273
2011-12-09 19:57:29 +00:00
Rafael Espindola
0a7f336475
Handle the case of the magical _GLOBAL_OFFSET_TABLE_ showing up in a
...
symbol difference. This matches gas behavior and fixes PR11513.
We still don't handle _GLOBAL_OFFSET_TABLE_ in data sections.
llvm-svn: 146238
2011-12-09 03:03:58 +00:00
Nick Lewycky
3e01bd3b60
Apparently, sometimes llvm-nm doesn't put the undefined symbol at the top. Take
...
that into account and test for no U's showing up in the middle, which is what
we really wanted to test for.
llvm-svn: 141653
2011-10-11 06:58:11 +00:00
Nick Lewycky
29e7b315ac
Also create a shndx even if there are no symbols. This lets us test
...
.symtab_shndx reading and writing together, and finally we have a testcase for
r141440.
llvm-svn: 141641
2011-10-11 03:54:50 +00:00
Rafael Espindola
77dde89b90
Fix the bitwidth of the remaining fields.
...
llvm-svn: 136884
2011-08-04 17:00:11 +00:00
Rafael Espindola
9bc32a96be
print st_shndx with the correct number of bits.
...
llvm-svn: 136880
2011-08-04 15:50:13 +00:00
Rafael Espindola
9528995e3f
print st_other with the correct number of bits.
...
llvm-svn: 136877
2011-08-04 15:38:19 +00:00
Rafael Espindola
96df560ce1
print st_type with the correct number of bits.
...
llvm-svn: 136875
2011-08-04 15:24:00 +00:00
Rafael Espindola
79ef75dc49
Print st_bind with the correct number of bits.
...
llvm-svn: 136874
2011-08-04 15:10:35 +00:00
Rafael Espindola
1848231ad1
Print r_sym with the correct number of bits.
...
llvm-svn: 136873
2011-08-04 14:48:27 +00:00
Rafael Espindola
260af5cef6
Print r_type with the correct number of bits.
...
llvm-svn: 136872
2011-08-04 14:39:30 +00:00
Rafael Espindola
1b282e7e49
Another counter goes decimal.
...
llvm-svn: 136871
2011-08-04 14:27:46 +00:00
Rafael Espindola
65c559c5fb
Change anther counter to decimal.
...
llvm-svn: 136870
2011-08-04 14:01:03 +00:00
Rafael Espindola
cad9e7f094
Don't print a counter in hex.
...
llvm-svn: 136869
2011-08-04 13:39:15 +00:00
Rafael Espindola
69c67d3b18
Print all the bits in the addend.
...
llvm-svn: 136867
2011-08-04 13:00:24 +00:00
Jason W Kim
e4df09f7ba
Fix http://llvm.org/bugs/show_bug.cgi?id=10568
...
Move the reloc size assert into AsmBackend - where it is more apropos.
llvm-svn: 136855
2011-08-04 00:38:45 +00:00
Eli Friedman
ae60b6b008
Extend the hack for _GLOBAL_OFFSET_TABLE_ slightly; PR10389.
...
llvm-svn: 135607
2011-07-20 19:36:11 +00:00
Eli Friedman
3846acc98e
PR10370: Make sure we know how to relax push correctly on x86-64.
...
llvm-svn: 135303
2011-07-15 21:28:39 +00:00
Kevin Enderby
6aac575c9f
Update MC/ELF/relocation.s with change to X86 PUSH64i8 in r134501.
...
llvm-svn: 134511
2011-07-06 17:55:20 +00:00
Nick Lewycky
34fa1684e7
Add support for @GOTPTOFF in i386 mode.
...
llvm-svn: 132643
2011-06-04 17:38:07 +00:00
Rafael Espindola
2e84c82750
Use %rbp on a 64 bit test.
...
llvm-svn: 132279
2011-05-29 04:04:50 +00:00
Benjamin Kramer
41112a1703
Move ARM specific test into the ARM subdir.
...
llvm-svn: 132255
2011-05-28 11:01:30 +00:00
Rafael Espindola
0fc5e89c82
ADD64ri32 sign extends its argument, so we need to use a R_X86_64_32S.
...
Fixes PR9934.
We really need to start tblgening the relocation info :-(
llvm-svn: 131669
2011-05-19 20:32:34 +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
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
1ecb12fc57
Add support for producing .deubg_frame sections.
...
llvm-svn: 131121
2011-05-10 03:54:12 +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
Rafael Espindola
82065cb6cf
Implement cfi_rel_offset
...
llvm-svn: 129306
2011-04-11 21:49:50 +00:00
Rafael Espindola
4f46abc15e
Add test for previous commit.
...
llvm-svn: 129304
2011-04-11 21:41:34 +00:00
Rafael Espindola
9a1a34b105
Update tests
...
llvm-svn: 129116
2011-04-07 23:51:25 +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
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
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
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
Chris Lattner
78178749e9
split this test into arch specific pieces, so the ARM
...
test isn't run when the arm backend isn't built. This
fixes PR9327
llvm-svn: 126500
2011-02-25 19:06:35 +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
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
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
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
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
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
Rafael Espindola
78c9f78fc9
Jörg Sonnenberger noticed that we were missing this test.
...
llvm-svn: 124139
2011-01-24 19:40:38 +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
ec517cdf24
Update tests.
...
llvm-svn: 123591
2011-01-16 18:02:57 +00:00
Evan Cheng
f02ca16ba7
Convert MC tests to .s so codegen changes won't break them.
...
llvm-svn: 122786
2011-01-03 23:47:14 +00:00
Rafael Espindola
3686473578
Fix PR8878.
...
llvm-svn: 122658
2011-01-01 19:05:35 +00:00
Rafael Espindola
46a5b05207
Correctly encode pcrel|indirect.
...
llvm-svn: 122624
2010-12-29 04:31:26 +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
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
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
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
Rafael Espindola
73c0ae77ca
Simplify the handling of .size expressions.
...
llvm-svn: 122404
2010-12-22 16:03:00 +00:00
Roman Divacky
55184ddd35
Set the value of absolute symbols.
...
llvm-svn: 122268
2010-12-20 21:14:39 +00:00
Roman Divacky
e15f591de4
Print all 64bits for st_value and st_size. Adjust tests accordingly.
...
llvm-svn: 122263
2010-12-20 20:49:43 +00:00
Rafael Espindola
2140ff508f
Add a test that shows that we produce no fixups when computing the difference
...
of two symbols in the same fragment.
llvm-svn: 122145
2010-12-18 05:07:45 +00:00
Rafael Espindola
af5ab7ad26
Test for push being relaxed.
...
llvm-svn: 122124
2010-12-18 01:16:59 +00:00
Rafael Espindola
32c74ea3ab
"Fix" FDE alignment to match what gas does.
...
llvm-svn: 122006
2010-12-17 00:28:02 +00:00
Rafael Espindola
654cc4a81c
Make pushq produce signed relocations.
...
llvm-svn: 122005
2010-12-16 22:50:01 +00:00
Rafael Espindola
0a017a6db2
Fixed version of 121434 with no new memory leaks.
...
llvm-svn: 121471
2010-12-10 07:39:47 +00:00
Rafael Espindola
a945a34c73
Revert my previous patch to make the valgrind bots happy.
...
llvm-svn: 121461
2010-12-10 04:01:09 +00:00
Rafael Espindola
56eb741237
Initial support for the cfi directives. This is just enough to get
...
f:
.cfi_startproc
nop
.cfi_endproc
assembled (on ELF).
llvm-svn: 121434
2010-12-09 23:48:29 +00:00
Rafael Espindola
1048e75fb9
Next step: Only pad debug_line when the target is darwin. Add a FIXME to avoid
...
doing that if the target is darwin10 or newer.
This fixes
*) Direct object emission was producing objects without the workaround on
darwin9.
*) Assembly printing was producing objects with the workaround on linux.
llvm-svn: 120866
2010-12-04 00:31:13 +00:00
Benjamin Kramer
e6840ef4b3
Fix some broken CHECK lines.
...
llvm-svn: 120332
2010-11-29 22:34:55 +00:00
Rafael Espindola
f8e127eaf6
Factor some code to parseSectionFlags and fix the default type of a section.
...
llvm-svn: 120145
2010-11-25 15:32:56 +00:00
Rafael Espindola
9f75d5df0b
Behave a bit more like gnu as and use the symbol (instead of the section)
...
for any relocation to a symbol defined in a tls section.
llvm-svn: 120121
2010-11-24 21:57:39 +00:00
Rafael Espindola
708ac4d6ad
Relocate with the symbol if the relocation is of kind NTPOFF.
...
Patch by David Meyer, I added the test.
llvm-svn: 120104
2010-11-24 19:23:50 +00:00
Rafael Espindola
e98d483b71
Fix and add tests for all cases in x86 and x86_64 where gnu as implicitly
...
sets the type of a symbol to STT_TLS.
llvm-svn: 120100
2010-11-24 18:51:21 +00:00
Rafael Espindola
4e70ac7b68
If a symbol is used as tls, mark it as tls even if not declare as so. Probably
...
fixes PR8659.
llvm-svn: 120076
2010-11-24 02:19:40 +00:00
Rafael Espindola
3c7cab1402
Produce a relocation for pcrel absolute values. Based on a patch by David Meyer.
...
llvm-svn: 120006
2010-11-23 07:20:12 +00:00
Rafael Espindola
26cb15a549
Handle PCRel relocations with absolute values. Fixes PR8656.
...
llvm-svn: 119917
2010-11-21 00:48:25 +00:00
Rafael Espindola
b67912d5cd
Add support for .int.
...
llvm-svn: 119512
2010-11-17 16:24:40 +00:00
Rafael Espindola
5c996894bd
Add support for .2byte, .4byte and .8byte.
...
Fixes PR8631.
llvm-svn: 119511
2010-11-17 16:15:42 +00:00
Rafael Espindola
7d19efd6ff
A bit more of gnu as compatibility when handling relocations with aliases.
...
llvm-svn: 119328
2010-11-16 04:11:46 +00:00
Rafael Espindola
8c3039b67b
Change MCExpr::EvaluateAsRelocatableImpl of variables to return the original
...
variable if recursing fails to simplify it.
Factor AliasedSymbol to be a method of MCSymbol.
Update MCAssembler::EvaluateFixup to match the change in
EvaluateAsRelocatableImpl.
Remove the WeakRefExpr hack, as the object writer now sees the weakref with
no extra effort needed.
Nothing else is using MCTargetExpr, but keep it for now.
Now that the ELF writer sees relocations with aliases, handle
.weak foo2
foo2:
.weak bar2
.set bar2,foo2
.quad bar2
the same way gas does and produce a relocation with bar2.
llvm-svn: 119152
2010-11-15 16:33:49 +00:00
Rafael Espindola
46c79ef113
Fix PR8565.
...
This moves most of the isUsed logic to the MCSymbol itself. With this we
get a bit more relaxed about allowing definitions after uses: uses that
don't evaluate their argument immediately (jmp foo) are accepted.
ddunbar, this was the smallest compromise I could think of that lets us
accept gcc (and clang!) assembly.
llvm-svn: 119144
2010-11-15 14:40:36 +00:00
Rafael Espindola
240028d11d
Move the logic to decide with which symbol we produce a relocation (if any) to
...
a central location. This also makes us a bit more compatible with gas.
llvm-svn: 119094
2010-11-14 23:53:26 +00:00
Rafael Espindola
a7d0bed336
Fix another case of a .comm directive without a corresponding .type
...
directive.
llvm-svn: 119073
2010-11-14 21:11:16 +00:00
Rafael Espindola
b05ef7377a
Fix the type of a symbol created with .comm and no corresponding .type.
...
llvm-svn: 119060
2010-11-14 19:40:55 +00:00
Rafael Espindola
7d0ba3464e
Handle a peculiar comdat case: Creating a section with an undefined
...
signature symbol causes a local symbol to be created unless there is
some other use of the symbol.
llvm-svn: 119026
2010-11-14 04:17:37 +00:00
Rafael Espindola
4bcf94c75a
Parse and record the gnu_unique_object type.
...
llvm-svn: 118980
2010-11-13 04:51:02 +00:00
Rafael Espindola
1d37f35eea
Fix the encoding of negative line deltas.
...
llvm-svn: 118962
2010-11-13 01:06:27 +00:00
Rafael Espindola
de990b270d
gnu as support both % and @ before types, do the same.
...
llvm-svn: 118893
2010-11-12 15:47:08 +00:00
Rafael Espindola
84d031870c
Mark labels declared in tls sections as STT_TLS. This matches the behavior of
...
gas.
llvm-svn: 118818
2010-11-11 19:04:55 +00:00
Rafael Espindola
a3e9a2298d
Initial comdat implementation.
...
llvm-svn: 118805
2010-11-11 18:13:52 +00:00
Rafael Espindola
fb6540c112
Make AliasedSymbol able to handle MCTargetExpr. They can get here if
...
a weakref is used with a VariantKind.
llvm-svn: 118798
2010-11-11 17:24:43 +00:00
Rafael Espindola
fa7b55754c
Fix the symbol index of weak references. Also make RecordRelocation a bit
...
easier to read by having const references to the symbol, aliased symbol and
renamed symbol.
llvm-svn: 118793
2010-11-11 16:48:11 +00:00
Rafael Espindola
9d17a3194e
Set default flags for .rodata.
...
llvm-svn: 118395
2010-11-08 02:47:59 +00:00
Rafael Espindola
5665a93bc5
Relax dwarf line fragments. This fixes a crash in the included testcase.
...
llvm-svn: 118365
2010-11-07 02:07:12 +00:00
Rafael Espindola
5e874982f2
Add support for expressions in .sleb/.uleb directives.
...
llvm-svn: 118023
2010-11-02 17:22:24 +00:00
Rafael Espindola
55ebc962ab
Fix test.
...
llvm-svn: 117932
2010-11-01 17:10:53 +00:00
Rafael Espindola
13ddd6d410
Write the line info to .debug_line.
...
llvm-svn: 117930
2010-11-01 17:07:14 +00:00
Rafael Espindola
1614597873
Implement .weakref.
...
llvm-svn: 117911
2010-11-01 14:28:48 +00:00
Rafael Espindola
45834a0065
Be more strict on when we produce an undefined reference. In gas a file with
...
just
.type foo,@object
will produce an undefined reference to foo. On the other hand, a file with
just
.weakref bar, foo
will not. It is somewhat hard to support both in MC since both statements
should create the symbols. It should be possible if we really need to by
adding to the flags, but hopefully that is not necessary.
With this patch we do not produce a undefined reference in any of those cases.
The assembly file needs an actual use for the undefined reference to be
present.
This is in preparation for a patch implementing .weakref.
llvm-svn: 117735
2010-10-29 23:09:31 +00:00
Rafael Espindola
8aefb66376
Improvements to .section parsing:
...
* If we have a M or a G, reject sections without the type
* Only parse the flag specific arguments if we have M or G
* Parse the corresponding arguments for M and G
We ignore the G arguments and flag for now.
llvm-svn: 117608
2010-10-28 21:33:33 +00:00
Rafael Espindola
3c5a54e4b9
Defined weak symbols should have non-zero value.
...
llvm-svn: 117585
2010-10-28 19:39:57 +00:00
Rafael Espindola
29f70afbae
Fix relocations with renamed symbols.
...
llvm-svn: 117575
2010-10-28 19:08:03 +00:00
Rafael Espindola
6cd76e63f8
Aliases defined with .symver should copy the binding of the symbols they alias.
...
Move the existing patching for undefined symbols so that all the patching
is done in the same function.
llvm-svn: 117570
2010-10-28 18:33:03 +00:00
Rafael Espindola
936ba3af28
Implement R_X86_64_DTPOFF32.
...
llvm-svn: 117548
2010-10-28 15:11:03 +00:00
Rafael Espindola
2dbec3f762
Implement TLSLD.
...
llvm-svn: 117547
2010-10-28 15:02:40 +00:00
Rafael Espindola
e8f08be11c
Implement DTPOFF.
...
llvm-svn: 117546
2010-10-28 14:48:59 +00:00
Rafael Espindola
6f23eb380d
Implement TLSLDM.
...
llvm-svn: 117544
2010-10-28 14:37:09 +00:00
Rafael Espindola
b3b49bbc39
Implement VK_GOTNTPOFF and switch RelocNeedsGOT to use VariantKind.
...
llvm-svn: 117543
2010-10-28 14:22:44 +00:00
Rafael Espindola
f8537165bd
Add support for R_386_TLS_GD, R_386_TLS_LE_32, R_386_TLS_IE and R_386_TLS_LE.
...
llvm-svn: 117494
2010-10-27 21:23:52 +00:00
Rafael Espindola
24c8b04d5f
Implement R_X86_64_GOTTPOFF, R_X86_64_TLSGD and R_X86_64_TPOFF32.
...
llvm-svn: 117481
2010-10-27 20:28:07 +00:00
Rafael Espindola
095fa9e5cc
Set default type and flags for .init and .fini.
...
llvm-svn: 117471
2010-10-27 18:45:20 +00:00
Rafael Espindola
26496e6835
Produce an error for an invalid use of .symver.
...
llvm-svn: 117462
2010-10-27 17:56:18 +00:00
Rafael Espindola
cc1b168ef6
Symbols defined as the difference of other two end up in the ABS section.
...
llvm-svn: 117451
2010-10-27 16:04:30 +00:00
Rafael Espindola
eb0c2c170d
Add support for the .symver directive. This is really ugly, but most of it is
...
contained in the ELF object writer.
llvm-svn: 117448
2010-10-27 15:18:17 +00:00
Rafael Espindola
c9fb35e73b
Add support for .ident.
...
llvm-svn: 117389
2010-10-26 19:35:47 +00:00
Rafael Espindola
e8ae98817a
Implement some relaxations for arithmetic instructions. The limitation
...
on RIP relative relocations looks artificial, but this is a superset of
what we were able to do before.
llvm-svn: 117364
2010-10-26 14:09:12 +00:00
Rafael Espindola
8ba86f801d
Do not recurse into symbol refs that have a variant kind. This prevents us
...
from losing the variant when producing a relocation on an alias.
llvm-svn: 117037
2010-10-21 18:00:20 +00:00
Rafael Espindola
89f6613e76
Handle _GLOBAL_OFFSET_TABLE_ correctly.
...
llvm-svn: 116932
2010-10-20 16:46:08 +00:00
Jason W Kim
e8b3711ae9
Fixing r116753 r116756 r116777
...
The failures in r116753 r116756 were caused by a python issue -
Python likes to append 'L' suffix to stringified numbers if the number
is larger than a machine int. Unfortunately, this causes a divergence of
behavior between 32 and 64 bit python versions.
I re-crafted elf-dump/common_dump to take care of these issues by:
1. always printing 0x (makes for easy sed/regex)
2. always print fixed length (exactly 2 + numBits/4 digits long)
by mod ((2^numBits) - 1)
3. left-padded with '0'
There is a residual common routine that is also used by
macho-dump (dataToHex) , so I left the 'section_data' test values alone.
llvm-svn: 116823
2010-10-19 17:39:10 +00:00
Eric Christopher
eac5e381cc
Speculatively revert 116753 and 116756 to attempt to fix the bots.
...
llvm-svn: 116777
2010-10-19 00:19:49 +00:00
Jason W Kim
eae048885d
Changed elf-dump to output hex format by default.
...
Also updated tests.
llvm-svn: 116753
2010-10-18 21:32:41 +00:00
Rafael Espindola
fba9f74932
Implement R_386_GOT32.
...
llvm-svn: 116744
2010-10-18 20:47:21 +00:00
Rafael Espindola
0a5314fdb3
Relocate with .bss instead of using the symbol. Matches gas behavior.
...
llvm-svn: 116741
2010-10-18 20:25:33 +00:00
Rafael Espindola
e3dc9e2ea1
Produce ELF::R_386_GOTPC relocations.
...
llvm-svn: 116728
2010-10-18 18:36:12 +00:00
Rafael Espindola
3521f8467d
Produce a R_386_PLT32 when needed. Moved the default cases of switches to the
...
start for consistency.
llvm-svn: 116715
2010-10-18 16:58:03 +00:00
Rafael Espindola
4464e0858f
Handle GOTOFF correctly on i386.
...
llvm-svn: 116711
2010-10-18 16:38:04 +00:00
Rafael Espindola
4262a22225
Add a MCObjectFormat class so that code common to all targets that use a
...
single object format can be shared.
This also adds support for
mov zed+(bar-foo), %eax
on ELF and COFF targets.
llvm-svn: 116675
2010-10-16 18:23:53 +00:00
Rafael Espindola
fbcf0db7ee
Refactor code a bit and avoid creating unnecessary entries in the string
...
map.
llvm-svn: 116579
2010-10-15 15:39:06 +00:00
Rafael Espindola
bee6e9f8e0
Remove some code duplication.
...
llvm-svn: 116484
2010-10-14 16:34:44 +00:00
Rafael Espindola
af8b4871a8
Call InitSections in llc and clang so that the binaries produced by them
...
are easier to diff with those produced by llvm-mc.
llvm-svn: 116095
2010-10-08 19:37:38 +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
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
c58a37ea51
Don't crash in a strange .size directive.
...
llvm-svn: 115684
2010-10-05 21:02:45 +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
259bcdad06
Tests that now pass.
...
llvm-svn: 115622
2010-10-05 15:43:32 +00:00
Rafael Espindola
fd1fff8b19
Implement ELF::R_X86_64_GOTPCREL.
...
llvm-svn: 115547
2010-10-04 19:51:39 +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
Chris Lattner
a2f2c27b20
actually, move the elf tests into the existing elf dir.
...
llvm-svn: 115416
2010-10-02 18:53:48 +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
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
9d98ac645e
Add another test that now passes.
...
llvm-svn: 115137
2010-09-30 04:22:07 +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
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
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
Rafael Espindola
68e05d404a
Add a test that I forgot to add with a previous commit.
...
llvm-svn: 115036
2010-09-29 14:40:49 +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
Rafael Espindola
9ca41113f6
Make sure .text doesn't produce extra alignment.
...
llvm-svn: 114895
2010-09-27 21:40:27 +00:00
Rafael Espindola
75d65b9a03
Move ELF to HasReliableSymbolDifference=true. Also take the opportunity to put
...
symbols defined in merge sections in independent atoms.
llvm-svn: 114786
2010-09-25 05:42:19 +00:00
Rafael Espindola
cf1f985838
Reapply 114678 and 114667. Reverting them did not fix the bot:
...
http://google1.osuosl.org:8011/builders/llvm-gcc-i386-linux-selfhost/builds/69
llvm-svn: 114761
2010-09-24 21:19:03 +00:00
Rafael Espindola
3843bb9d2c
Revert 114678 and 114667 to see if
...
http://google1.osuosl.org:8011/builders/llvm-gcc-i386-linux-selfhost
gets happy.
llvm-svn: 114742
2010-09-24 18:48:08 +00:00
Rafael Espindola
f458f04eb1
Correctly handle weak undefined symbols. Before we would get a invalid binding
...
(2 == STB_WEAK | STB_GLOBAL).
llvm-svn: 114690
2010-09-23 19:55:14 +00:00
Rafael Espindola
48e108753b
Represent relocations against local symbols as relocations against the section
...
they are in. Both ways should be equivalent, but gas produces relocations
against the section.
Roman wrote the patch, I added the test.
llvm-svn: 114667
2010-09-23 17:25:18 +00:00
Rafael Espindola
dee12d8110
Avoid some Mach-O specific alignment being done on ELF.
...
llvm-svn: 114594
2010-09-22 22:27:05 +00:00
Rafael Espindola
9bac6cb544
Correctly align bss.
...
llvm-svn: 114556
2010-09-22 17:43:04 +00:00
Rafael Espindola
f0591c1642
Implement support for .local and its "interesting" interactions with .comm.
...
llvm-svn: 114382
2010-09-21 00:24:38 +00:00
Rafael Espindola
32ab4558fe
Produce a R_X86_64_32 when the value is >=0.
...
llvm-svn: 114339
2010-09-20 19:20:47 +00:00
Rafael Espindola
57e599a82a
Make sure the STT_FILE symbol is the first one in the symbol table.
...
llvm-svn: 114285
2010-09-18 15:03:21 +00:00
Rafael Espindola
15829c6c4c
Add test that was missing in my previous commit.
...
llvm-svn: 114248
2010-09-18 00:37:27 +00:00
Rafael Espindola
44bf266111
Print the address of sections as 0 and create the metadata sections in the
...
same order as gnu as.
llvm-svn: 114109
2010-09-16 19:46:31 +00:00
Rafael Espindola
f7f433200b
Make sure that names like .note.GNU-stack are accepted as valid section names.
...
llvm-svn: 114091
2010-09-16 17:05:55 +00:00
Rafael Espindola
922e3f454b
Add support for the .zero directive.
...
llvm-svn: 114077
2010-09-16 15:03:59 +00:00
Rafael Espindola
f667d929ce
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.
llvm-svn: 114027
2010-09-15 21:48:40 +00:00
Rafael Espindola
12d73d1f18
Add support for leb128 of absolute expressions.
...
llvm-svn: 113691
2010-09-11 16:45:15 +00:00
Benjamin Kramer
0a96578ac0
Add an elf-dumper utility.
...
- Output format and some of the code stolen from macho-dump.
- Somewhat incomplete and probably buggy.
- Comes with a very basic test.
llvm-svn: 113488
2010-09-09 15:00:41 +00:00
Daniel Dunbar
8e92d9b68d
MC/ELF: Allow null values in virtual sections, ELF doesn't use special
...
directives for putting contents in .bss, for example.
llvm-svn: 111376
2010-08-18 18:22:37 +00:00