summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/ELF/relocation.s
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-readobj] Change -long-option to --long-option in tests. NFCFangrui Song2019-05-011-1/+1
| | | | | | | | | | We use both -long-option and --long-option in tests. Switch to --long-option for consistency. In the "llvm-readelf" mode, -long-option is discouraged as it conflicts with grouped short options and it is not accepted by GNU readelf. While updating the tests, change llvm-readobj -s to llvm-readobj -S to reduce confusion ("s" is --section-headers in llvm-readobj but --symbols in llvm-readelf). llvm-svn: 359649
* [MC] [X86] Teach leaq _GLOBAL_OFFSET_TABLE(%rip), %r15 to use ↵Fangrui Song2018-06-121-13/+17
| | | | | | | | | | | | | | | | | | | R_X86_64_GOTPC32 instead of R_X86_64_PC32 Summary: This is similar to D46319 (ARM). x86-64 psABI p40 gives an example: leaq _GLOBAL_OFFSET_TABLE(%rip), %r15 # GOTPC32 reloc GNU as creates R_X86_64_GOTPC32. However, MC currently emits R_X86_64_PC32. Reviewers: javed.absar, echristo Subscribers: kristof.beyls, llvm-commits, peter.smith, grimar Differential Revision: https://reviews.llvm.org/D47507 llvm-svn: 334515
* Accept subtractions involving a weak symbol.Rafael Espindola2016-01-201-0/+6
| | | | | | | | | | | | | | | | | | When a symbol S shows up in an expression in assembly there are two possible interpretations * The expression is referring to the value of S in this file. * The expression is referring to the value after symbol resolution. In the first case the assembler can reason about the value and try to produce a relocation. In the second case, that is only possible if the symbol cannot be preempted. Assemblers are not very consistent about which interpretation gets used. This changes MC to agree with GAS in the case of an expression of the form "Sym - WeakSym". llvm-svn: 258329
* Fix pr24486.Rafael Espindola2015-10-051-1/+7
| | | | | | | | | | | | | | | | | | This extends the work done in r233995 so that now getFragment (in addition to getSection) also works for variable symbols. With that the existing logic to decide if a-b can be computed works even if a or b are variables. Given that, the expression evaluation can avoid expanding variables as aggressively and that in turn lets the relocation code see the original variable. In order for this to work with the asm streamer, there is now a dummy fragment per section. It is used to assign a section to a symbol when no other fragment exists. This patch is a joint work by Maxim Ostapenko andy myself. llvm-svn: 249303
* Handle 16 bit PC relative relocations.Rafael Espindola2015-06-061-0/+5
| | | | | | Fixes pr23771. llvm-svn: 239214
* Fix the interpretation of a 0 st_name.Rafael Espindola2015-06-031-11/+1
| | | | | | | | | | | | | | The ELF spec is very clear: ----------------------------------------------------------------------------- If the value is non-zero, it represents a string table index that gives the symbol name. Otherwise, the symbol table entry has no name. -------------------------------------------------------------------------- In particular, a st_name of 0 most certainly doesn't mean that the symbol has the same name as the section. llvm-svn: 238899
* Look past locals in comdats.Rafael Espindola2015-04-201-0/+2
| | | | | | | | | | | We have to avoid converting a reference to a global into a reference to a local, but it is fine to look past a local. Patch by Vasileios Kalintiris. I just moved the comment and added thet test. llvm-svn: 235300
* Compute A-B if both A and B are in the same comdat section.Rafael Espindola2015-04-171-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of pr23272. A small annoyance with the assembly syntax we implement is that given an expression there is no way to know if what is desired is the value of that expression for the symbols in this file or for the final values of those symbols in a link. The first case is useful for use in sections that get discarded or ignored if the section they are describing is discarded. For axample, consider A-B where A and B are in the same comdat section. We can compute the value of the difference in the section that is present in the current .o and if that section survives to the final DSO the value will still will be correct. But the section is in a comdat. Another section from another object file might be used istead. We know that that section will define A and B, but we have no idea what the value of A-B might be. In practice we have to assume that the intention is to compute the value in the current section since otherwise the is no way to create something like the debug aranges section. llvm-svn: 235222
* Reorganize the x86 ELF relocation selection logic.Rafael Espindola2015-03-201-0/+4
| | | | | | | | | | | | | | | The main differences are: * Split in 32 and 64 bit functions. * First switch on the Modifier so that we have only one non fully covered switch. * Map the fixup kind first to a x86_64 (or i386) specific enum, to make it easy to handle cases like X86::reloc_riprel_4byte_movq_load. * Switch on IsPCRel last, which reduces code duplication. Fixes pr22308. llvm-svn: 232837
* [MC][Target] Implement support for R_X86_64_SIZE{32,64}.Davide Italiano2015-03-041-0/+13
| | | | | | | Differential Revision: D7990 Reviewed by: rafael, majnemer llvm-svn: 231216
* Fix pr19645.Rafael Espindola2014-05-031-1/+2
| | | | | | | | | | | | | | | | The fix itself is fairly simple: move getAccessVariant to MCValue so that we replace the old weak expression evaluation with the far more general EvaluateAsRelocatable. This then requires that EvaluateAsRelocatable stop when it finds a non trivial reference kind. And that in turn requires the ELF writer to look harder for weak references. Last but not least, this found a case where we were being bug by bug compatible with gas and accepting an invalid input. I reported pr19647 to track it. llvm-svn: 207920
* Handle _GLOBAL_OFFSET_TABLE_ in 64 bit mode.Rafael Espindola2014-04-211-0/+5
| | | | | | | | | With this MC is able to handle _GLOBAL_OFFSET_TABLE_ in 64 bit mode, which is needed for medium and large code models. This fixes pr19470. llvm-svn: 206793
* Fix up MCFixup::getAccessVariant to handle unary expressions.Kaelyn Takata2014-04-141-0/+3
| | | | | | | | | | | | This allows correct relocations to be generated for a symbolic address that is being adjusted by a negative constant. Since r204294, such expressions have triggered undefined behavior when LLVM was built without assertions. Credit goes to Rafael for this patch; I'm submitting it on his behalf as he is on vacation this week. llvm-svn: 206192
* Look through variables when computing relocations.Rafael Espindola2014-03-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given bar = foo + 4 .long bar MC would eat the 4. GNU as includes it in the relocation. The rule seems to be that a variable that defines a symbol is used in the relocation and one that does not define a symbol is evaluated and the result included in the relocation. Fixing this unfortunately required some other changes: * Since the variable is now evaluated, it would prevent the ELF writer from noticing the weakref marker the elf streamer uses. This patch then replaces that with a VariantKind in MCSymbolRefExpr. * Using VariantKind then requires us to look past other VariantKind to see .weakref bar,foo call bar@PLT doing this also fixes zed = foo +2 call zed@PLT so that is a good thing. * Looking past VariantKind means that the relocation selection has to use the fixup instead of the target. This is a reboot of the previous fixes for MC. I will watch the sanitizer buildbot and wait for a build before adding back the previous fixes. llvm-svn: 204294
* [x86] Support R_386_PC8, R_386_PC16 and R_X86_64_PC8David Woodhouse2014-01-081-0/+4
| | | | llvm-svn: 198763
* This commit adds some (but not all) of the x86-64 relocations that are notTom Roeder2013-10-301-6/+10
| | | | | | currently supported in the ELF object writer, along with a simple test case. llvm-svn: 193709
* X86: Use R_X86_64_TPOFF64 for FK_Data_8David Majnemer2013-09-221-0/+2
| | | | | | | | | | | | | | | | | | | Summary: LLVM would crash when trying to come up with a relocation type for assembly like: movabsq $V@TPOFF, %rax Instead, we say the relocation type is R_X86_64_TPOFF64. Fixes PR17274. Reviewers: dblaikie, nrieck, rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1717 llvm-svn: 191163
* Integrate Assembler: Support X86_64_DTPOFF64 relocationsDavid Blaikie2013-06-281-1/+2
| | | | llvm-svn: 185131
* Change how we iterate over relocations on ELF.Rafael Espindola2013-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | For COFF and MachO, sections semantically have relocations that apply to them. That is not the case on ELF. In relocatable objects (.o), a section with relocations in ELF has offsets to another section where the relocations should be applied. In dynamic objects and executables, relocations don't have an offset, they have a virtual address. The section sh_info may or may not point to another section, but that is not actually used for resolving the relocations. This patch exposes that in the ObjectFile API. It has the following advantages: * Most (all?) clients can handle this more efficiently. They will normally walk all relocations, so doing an effort to iterate in a particular order doesn't save time. * llvm-readobj now prints relocations in the same way the native readelf does. * probably most important, relocations that don't point to any section are now visible. This is the case of relocations in the rela.dyn section. See the updated relocation-executable.test for example. llvm-svn: 182908
* Replace coff-/elf-dump with llvm-readobjNico Rieck2013-04-121-100/+31
| | | | llvm-svn: 179361
* Fix the bitwidth of the remaining fields.Rafael Espindola2011-08-041-15/+15
| | | | llvm-svn: 136884
* print st_shndx with the correct number of bits.Rafael Espindola2011-08-041-1/+1
| | | | llvm-svn: 136880
* print st_other with the correct number of bits.Rafael Espindola2011-08-041-1/+1
| | | | llvm-svn: 136877
* print st_type with the correct number of bits.Rafael Espindola2011-08-041-1/+1
| | | | llvm-svn: 136875
* Print st_bind with the correct number of bits.Rafael Espindola2011-08-041-1/+1
| | | | llvm-svn: 136874
* Another counter goes decimal.Rafael Espindola2011-08-041-1/+1
| | | | llvm-svn: 136871
* Change anther counter to decimal.Rafael Espindola2011-08-041-15/+15
| | | | llvm-svn: 136870
* Don't print a counter in hex.Rafael Espindola2011-08-041-1/+1
| | | | llvm-svn: 136869
* Print all the bits in the addend.Rafael Espindola2011-08-041-9/+9
| | | | llvm-svn: 136867
* PR10370: Make sure we know how to relax push correctly on x86-64.Eli Friedman2011-07-151-5/+5
| | | | llvm-svn: 135303
* Update MC/ELF/relocation.s with change to X86 PUSH64i8 in r134501.Kevin Enderby2011-07-061-5/+5
| | | | llvm-svn: 134511
* ADD64ri32 sign extends its argument, so we need to use a R_X86_64_32S.Rafael Espindola2011-05-191-0/+7
| | | | | | | | Fixes PR9934. We really need to start tblgening the relocation info :-( llvm-svn: 131669
* Update testsRafael Espindola2011-04-071-1/+1
| | | | llvm-svn: 129116
* Write the section table and the section data in the same order thatRafael Espindola2011-03-201-7/+7
| | | | | | | 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
* Add support for lowercase variants.Rafael Espindola2011-01-231-1/+1
| | | | llvm-svn: 124071
* Fix PR8878.Rafael Espindola2011-01-011-0/+7
| | | | llvm-svn: 122658
* Handle reloc_riprel_4byte_movq_load. Should make the bots happy.Rafael Espindola2010-12-271-0/+7
| | | | llvm-svn: 122579
* Make pushq produce signed relocations.Rafael Espindola2010-12-161-0/+8
| | | | llvm-svn: 122005
* Fix some broken CHECK lines.Benjamin Kramer2010-11-291-1/+1
| | | | llvm-svn: 120332
* Implement R_X86_64_DTPOFF32.Rafael Espindola2010-10-281-0/+7
| | | | llvm-svn: 117548
* Implement TLSLD.Rafael Espindola2010-10-281-0/+7
| | | | llvm-svn: 117547
* Implement R_X86_64_GOTTPOFF, R_X86_64_TLSGD and R_X86_64_TPOFF32.Rafael Espindola2010-10-271-7/+28
| | | | llvm-svn: 117481
* Fixing r116753 r116756 r116777Jason W Kim2010-10-191-34/+34
| | | | | | | | | | | | | | | | | | | 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
* Speculatively revert 116753 and 116756 to attempt to fix the bots.Eric Christopher2010-10-191-34/+34
| | | | llvm-svn: 116777
* Changed elf-dump to output hex format by default.Jason W Kim2010-10-181-34/+34
| | | | | | Also updated tests. llvm-svn: 116753
* Factor some logic into ShouldRelocOnSymbol. This simplifies the code andRafael Espindola2010-09-301-6/+15
| | | | | | | fixes some cases where we were producing relocations with at symbol that should use a section instead. llvm-svn: 115194
* Correctly produce R_X86_64_32 or R_X86_64_32S.Rafael Espindola2010-09-301-5/+41
| | | | | | | | | | | | | 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
* Produce a R_X86_64_32 when the value is >=0.Rafael Espindola2010-09-201-0/+12
llvm-svn: 114339
OpenPOWER on IntegriCloud