summaryrefslogtreecommitdiff
path: root/lib/CodeGen/ELFWriter.h
Commit message (Collapse)AuthorAge
* Fix a FIXME by making GlobalVariable::getInitializer() return aJay Foad2011-06-19
| | | | | | const Constant *. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133400 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy some #includes and forward-declarations, and move the C binding codeDan Gohman2010-08-07
| | | | | | | out of PassManager.cpp and into Core.cpp with the rest of the C binding code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110494 91177308-0d34-0410-b5e6-96231b3b80d8
* Get rid of a bunch of duplicated ELF enum values.Eli Friedman2010-07-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108520 91177308-0d34-0410-b5e6-96231b3b80d8
* Add more const qualifiers for LLVM IR pointers in CodeGen.Dan Gohman2010-04-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101342 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the JIT side of the GDB JIT debugging interface. To enable thisReid Kleckner2009-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | feature, either build the JIT in debug mode to enable it by default or pass -jit-emit-debug to lli. Right now, the only debug information that this communicates to GDB is call frame information, since it's already being generated to support exceptions in the JIT. Eventually, when DWARF generation isn't tied so tightly to AsmPrinter, it will be easy to push that information to GDB through this interface. Here's a step-by-step breakdown of how the feature works: - The JIT generates the machine code and DWARF call frame info (.eh_frame/.debug_frame) for a function into memory. - The JIT copies that info into an in-memory ELF file with a symbol for the function. - The JIT creates a code entry pointing to the ELF buffer and adds it to a linked list hanging off of a global descriptor at a special symbol that GDB knows about. - The JIT calls a function marked noinline that GDB knows about and has put an internal breakpoint in. - GDB catches the breakpoint and reads the global descriptor to look for new code. - When sees there is new code, it reads the ELF from the inferior's memory and adds it to itself as an object file. - The JIT continues, and the next time we stop the program, we are able to produce a proper backtrace. Consider running the following program through the JIT: #include <stdio.h> void baz(short z) { long w = z + 1; printf("%d, %x\n", w, *((int*)NULL)); // SEGFAULT here } void bar(short y) { int z = y + 1; baz(z); } void foo(char x) { short y = x + 1; bar(y); } int main(int argc, char** argv) { char x = 1; foo(x); } Here is a backtrace before this patch: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x2aaaabdfbd10 (LWP 25476)] 0x00002aaaabe7d1a8 in ?? () (gdb) bt #0 0x00002aaaabe7d1a8 in ?? () #1 0x0000000000000003 in ?? () #2 0x0000000000000004 in ?? () #3 0x00032aaaabe7cfd0 in ?? () #4 0x00002aaaabe7d12c in ?? () #5 0x00022aaa00000003 in ?? () #6 0x00002aaaabe7d0aa in ?? () #7 0x01000002abe7cff0 in ?? () #8 0x00002aaaabe7d02c in ?? () #9 0x0100000000000001 in ?? () #10 0x00000000014388e0 in ?? () #11 0x00007fff00000001 in ?? () #12 0x0000000000b870a2 in llvm::JIT::runFunction (this=0x1405b70, F=0x14024e0, ArgValues=@0x7fffffffe050) at /home/rnk/llvm-gdb/lib/ExecutionEngine/JIT/JIT.cpp:395 #13 0x0000000000baa4c5 in llvm::ExecutionEngine::runFunctionAsMain (this=0x1405b70, Fn=0x14024e0, argv=@0x13f06f8, envp=0x7fffffffe3b0) at /home/rnk/llvm-gdb/lib/ExecutionEngine/ExecutionEngine.cpp:377 #14 0x00000000007ebd52 in main (argc=2, argv=0x7fffffffe398, envp=0x7fffffffe3b0) at /home/rnk/llvm-gdb/tools/lli/lli.cpp:208 And a backtrace after this patch: Program received signal SIGSEGV, Segmentation fault. 0x00002aaaabe7d1a8 in baz () (gdb) bt #0 0x00002aaaabe7d1a8 in baz () #1 0x00002aaaabe7d12c in bar () #2 0x00002aaaabe7d0aa in foo () #3 0x00002aaaabe7d02c in main () #4 0x0000000000b870a2 in llvm::JIT::runFunction (this=0x1405b70, F=0x14024e0, ArgValues=...) at /home/rnk/llvm-gdb/lib/ExecutionEngine/JIT/JIT.cpp:395 #5 0x0000000000baa4c5 in llvm::ExecutionEngine::runFunctionAsMain (this=0x1405b70, Fn=0x14024e0, argv=..., envp=0x7fffffffe3c0) at /home/rnk/llvm-gdb/lib/ExecutionEngine/ExecutionEngine.cpp:377 #6 0x00000000007ebd52 in main (argc=2, argv=0x7fffffffe3a8, envp=0x7fffffffe3c0) at /home/rnk/llvm-gdb/tools/lli/lli.cpp:208 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82418 91177308-0d34-0410-b5e6-96231b3b80d8
* rename TAI -> MAI, being careful not to make MAILJMP instructions :)Chris Lattner2009-08-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79777 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename TargetAsmInfo (and its subclasses) to MCAsmInfo.Chris Lattner2009-08-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79763 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove hack used to strip unwanted chars from section nameBruno Cardoso Lopes2009-08-13
| | | | | | | | | Use MCSectionELF methods as much as possible, removing some ELFWriter methods which are now unused git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78940 91177308-0d34-0410-b5e6-96231b3b80d8
* Move ConstantExpr handling to ResolveConstantExpr method and alsoBruno Cardoso Lopes2009-08-10
| | | | | | | add support for PtrToInt, Add, Mul. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78552 91177308-0d34-0410-b5e6-96231b3b80d8
* ELF improvements:Bruno Cardoso Lopes2009-08-08
| | | | | | | | | | | | | Handle large integers, x86_fp80, ConstantAggregateZero, and two more ConstantExpr: GetElementPtr and IntToPtr Set SHF_MERGE bit for mergeable strings Avoid zero initialized strings to be classified as a bss symbol Don't allow common symbols to be classified as STB_WEAK Add a constant to be used as a global value offset in data relocations git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78476 91177308-0d34-0410-b5e6-96231b3b80d8
* - Remove custom handling of jumptables by the elf writter (this wasBruno Cardoso Lopes2009-08-05
| | | | | | | | | | | | | | a dirty hack and isn't need anymore since the last x86 code emitter patch) - Add a target-dependent modifier to addend calculation - Use R_X86_64_32S relocation for X86::reloc_absolute_word_sext - Use getELFSectionFlags whenever possible - fix getTextSection to use TLOF and emit the right text section - Handle global emission for static ctors, dtors and Type::PointerTyID - Some minor fixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78176 91177308-0d34-0410-b5e6-96231b3b80d8
* refactor section construction in TLOF to be through an explicitChris Lattner2009-07-31
| | | | | | | initialize method, which can be called when an MCContext is available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77687 91177308-0d34-0410-b5e6-96231b3b80d8
* add module identifier to the elf object fileBruno Cardoso Lopes2009-07-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77238 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle external symbols for ELF and add some static methods to ELFSymBruno Cardoso Lopes2009-07-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77232 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate SectionFlags, just embed a SectionKind into SectionChris Lattner2009-07-27
| | | | | | | instead and drive things based off of that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77184 91177308-0d34-0410-b5e6-96231b3b80d8
* Support adding relocations for data sections, handling the cases whereBruno Cardoso Lopes2009-07-21
| | | | | | | | global declared symbols are initialized with references from other global symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76540 91177308-0d34-0410-b5e6-96231b3b80d8
* For PC relative relocations where symbols are defined in the same section theyBruno Cardoso Lopes2009-07-20
| | | | | | | | are referenced, ignore the relocation entry and patch the relocatable field with the computed symbol offset directly git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76414 91177308-0d34-0410-b5e6-96231b3b80d8
* Use R_X86_64_32S to handle Jump Table Index relocation entries. Hide TAI ↵Bruno Cardoso Lopes2009-07-18
| | | | | | usage inside getSection* functions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76347 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support to properly reference private symbols on relocation entries.Bruno Cardoso Lopes2009-07-18
| | | | | | | | Use proper relocation type to build relocations for JumpTables (rodata sections). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76326 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix coding style issues pointed by Bill.Bruno Cardoso Lopes2009-07-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75898 91177308-0d34-0410-b5e6-96231b3b80d8
* use std::vector instead of std::list for both Section and Symbol lists becauseBruno Cardoso Lopes2009-07-15
| | | | | | | we care more about random access than insertion/deletion of elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75828 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup the global emission and refactor some codeBruno Cardoso Lopes2009-07-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75537 91177308-0d34-0410-b5e6-96231b3b80d8
* Match declaration to definition.Daniel Dunbar2009-07-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75454 91177308-0d34-0410-b5e6-96231b3b80d8
* Changed ELFCodeEmitter to inherit from ObjectCodeEmitterBruno Cardoso Lopes2009-07-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74821 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor some code out and support for Jump Table relocationsBruno Cardoso Lopes2009-07-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74760 91177308-0d34-0410-b5e6-96231b3b80d8
* shrinking down #includesBruno Cardoso Lopes2009-07-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74718 91177308-0d34-0410-b5e6-96231b3b80d8
* Support Constant Pool SectionsBruno Cardoso Lopes2009-06-25
| | | | | | | Add section symbols to the symbol table git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74170 91177308-0d34-0410-b5e6-96231b3b80d8
* Use a default alignment for data and bss sections.Bruno Cardoso Lopes2009-06-23
| | | | | | | | | Only pad when the section size > 0 and move the code that deals with globals initializers to a place we know for sure the global is initialized. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73944 91177308-0d34-0410-b5e6-96231b3b80d8
* Use different functions to emit the string and symbol tables.Bruno Cardoso Lopes2009-06-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73895 91177308-0d34-0410-b5e6-96231b3b80d8
* Add more methods to gather target specific elf stuffBruno Cardoso Lopes2009-06-22
| | | | | | | | | | Support for .text relocations, implementing TargetELFWriter overloaded methods for x86/x86_64. Use a map to track global values to their symbol table indexes Code cleanup and small fixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73894 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce new BinaryObject (blob) class, ELF Writer modified to use it. ↵Bruno Cardoso Lopes2009-06-14
| | | | | | BinaryObject.h by Aaron Gray git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73333 91177308-0d34-0410-b5e6-96231b3b80d8
* Support for ELF VisibilityBruno Cardoso Lopes2009-06-11
| | | | | | | | | | Emission for globals, using the correct data sections Function alignment can be computed for each target using TargetELFWriterInfo Some small fixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73201 91177308-0d34-0410-b5e6-96231b3b80d8
* Simple ELF32/64 binary files can now be emitted for x86 and x86_64 withoutBruno Cardoso Lopes2009-06-07
| | | | | | | relocation sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73038 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove elf specific info from ELFWriter.h to Elf.h. Code cleanup and more ↵Bruno Cardoso Lopes2009-06-06
| | | | | | comments added git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72982 91177308-0d34-0410-b5e6-96231b3b80d8
* ELF Code Emitter now uses CurBufferPtr, BufferBegin and BufferEnd, as do JIT andBruno Cardoso Lopes2009-06-05
| | | | | | | | MachO Writer. This will change with the arrival of ObjectCodeEmitter and BinaryObject git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72906 91177308-0d34-0410-b5e6-96231b3b80d8
* Use raw_ostream throughout the AsmPrinter.Owen Anderson2008-08-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55092 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't include <map> in Pass.h, which doesn't need it. This requiresDan Gohman2008-03-21
| | | | | | | adding <map> to many files that actually do need it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48667 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
* Here is the bulk of the sanitizing.Gabor Greif2007-07-05
| | | | | | | Almost all occurrences of "bytecode" in the sources have been eliminated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37913 91177308-0d34-0410-b5e6-96231b3b80d8
* Drop 'const'Devang Patel2007-05-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36662 91177308-0d34-0410-b5e6-96231b3b80d8
* Use 'static const char' instead of 'static const int'.Devang Patel2007-05-02
| | | | | | | | Due to darwin gcc bug, one version of darwin linker coalesces static const int, which defauts PassID based pass identification. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36652 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not use typeinfo to identify pass in pass manager.Devang Patel2007-05-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36632 91177308-0d34-0410-b5e6-96231b3b80d8
* Moved from include/llvm/CodeGen to lib/CodeGen.Bill Wendling2007-02-08
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34027 91177308-0d34-0410-b5e6-96231b3b80d8