summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ELFWriter.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement the JIT side of the GDB JIT debugging interface. To enable thisReid Kleckner2009-09-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 82418
* rename TAI -> MAI, being careful not to make MAILJMP instructions :)Chris Lattner2009-08-221-3/+3
| | | | llvm-svn: 79777
* Rename TargetAsmInfo (and its subclasses) to MCAsmInfo.Chris Lattner2009-08-221-2/+2
| | | | llvm-svn: 79763
* Remove hack used to strip unwanted chars from section nameBruno Cardoso Lopes2009-08-131-41/+16
| | | | | | | Use MCSectionELF methods as much as possible, removing some ELFWriter methods which are now unused llvm-svn: 78940
* Move ConstantExpr handling to ResolveConstantExpr method and alsoBruno Cardoso Lopes2009-08-101-1/+3
| | | | | | add support for PtrToInt, Add, Mul. llvm-svn: 78552
* ELF improvements:Bruno Cardoso Lopes2009-08-081-2/+4
| | | | | | | | | | | 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 llvm-svn: 78476
* - Remove custom handling of jumptables by the elf writter (this wasBruno Cardoso Lopes2009-08-051-14/+19
| | | | | | | | | | | | 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 llvm-svn: 78176
* refactor section construction in TLOF to be through an explicitChris Lattner2009-07-311-0/+3
| | | | | | initialize method, which can be called when an MCContext is available. llvm-svn: 77687
* add module identifier to the elf object fileBruno Cardoso Lopes2009-07-271-1/+1
| | | | llvm-svn: 77238
* Handle external symbols for ELF and add some static methods to ELFSymBruno Cardoso Lopes2009-07-271-10/+23
| | | | llvm-svn: 77232
* Eliminate SectionFlags, just embed a SectionKind into SectionChris Lattner2009-07-271-1/+2
| | | | | | instead and drive things based off of that. llvm-svn: 77184
* Support adding relocations for data sections, handling the cases whereBruno Cardoso Lopes2009-07-211-0/+5
| | | | | | | global declared symbols are initialized with references from other global symbols. llvm-svn: 76540
* For PC relative relocations where symbols are defined in the same section theyBruno Cardoso Lopes2009-07-201-12/+3
| | | | | | | are referenced, ignore the relocation entry and patch the relocatable field with the computed symbol offset directly llvm-svn: 76414
* Use R_X86_64_32S to handle Jump Table Index relocation entries. Hide TAI ↵Bruno Cardoso Lopes2009-07-181-12/+4
| | | | | | usage inside getSection* functions llvm-svn: 76347
* Add support to properly reference private symbols on relocation entries.Bruno Cardoso Lopes2009-07-181-2/+6
| | | | | | | Use proper relocation type to build relocations for JumpTables (rodata sections). llvm-svn: 76326
* Fix coding style issues pointed by Bill.Bruno Cardoso Lopes2009-07-161-0/+3
| | | | llvm-svn: 75898
* use std::vector instead of std::list for both Section and Symbol lists becauseBruno Cardoso Lopes2009-07-151-14/+15
| | | | | | we care more about random access than insertion/deletion of elements. llvm-svn: 75828
* Cleanup the global emission and refactor some codeBruno Cardoso Lopes2009-07-131-3/+3
| | | | llvm-svn: 75537
* Match declaration to definition.Daniel Dunbar2009-07-131-1/+1
| | | | llvm-svn: 75454
* Changed ELFCodeEmitter to inherit from ObjectCodeEmitterBruno Cardoso Lopes2009-07-061-8/+8
| | | | llvm-svn: 74821
* Factor some code out and support for Jump Table relocationsBruno Cardoso Lopes2009-07-031-9/+30
| | | | llvm-svn: 74760
* shrinking down #includesBruno Cardoso Lopes2009-07-021-7/+12
| | | | llvm-svn: 74718
* Support Constant Pool SectionsBruno Cardoso Lopes2009-06-251-0/+6
| | | | | | Add section symbols to the symbol table llvm-svn: 74170
* Use a default alignment for data and bss sections.Bruno Cardoso Lopes2009-06-231-2/+6
| | | | | | | | 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. llvm-svn: 73944
* Use different functions to emit the string and symbol tables.Bruno Cardoso Lopes2009-06-221-0/+1
| | | | llvm-svn: 73895
* Add more methods to gather target specific elf stuffBruno Cardoso Lopes2009-06-221-14/+47
| | | | | | | | 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 llvm-svn: 73894
* Introduce new BinaryObject (blob) class, ELF Writer modified to use it. ↵Bruno Cardoso Lopes2009-06-141-17/+21
| | | | | | BinaryObject.h by Aaron Gray llvm-svn: 73333
* Support for ELF VisibilityBruno Cardoso Lopes2009-06-111-4/+27
| | | | | | | | Emission for globals, using the correct data sections Function alignment can be computed for each target using TargetELFWriterInfo Some small fixes llvm-svn: 73201
* Simple ELF32/64 binary files can now be emitted for x86 and x86_64 withoutBruno Cardoso Lopes2009-06-071-17/+11
| | | | | | relocation sections. llvm-svn: 73038
* Remove elf specific info from ELFWriter.h to Elf.h. Code cleanup and more ↵Bruno Cardoso Lopes2009-06-061-83/+7
| | | | | | comments added llvm-svn: 72982
* ELF Code Emitter now uses CurBufferPtr, BufferBegin and BufferEnd, as do JIT andBruno Cardoso Lopes2009-06-051-0/+6
| | | | | | | MachO Writer. This will change with the arrival of ObjectCodeEmitter and BinaryObject llvm-svn: 72906
* Use raw_ostream throughout the AsmPrinter.Owen Anderson2008-08-211-2/+3
| | | | llvm-svn: 55092
* Don't include <map> in Pass.h, which doesn't need it. This requiresDan Gohman2008-03-211-0/+1
| | | | | | adding <map> to many files that actually do need it. llvm-svn: 48667
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-291-2/+2
| | | | llvm-svn: 45418
* Here is the bulk of the sanitizing.Gabor Greif2007-07-051-1/+1
| | | | | | Almost all occurrences of "bytecode" in the sources have been eliminated. llvm-svn: 37913
* Drop 'const'Devang Patel2007-05-031-1/+1
| | | | llvm-svn: 36662
* Use 'static const char' instead of 'static const int'.Devang Patel2007-05-021-1/+1
| | | | | | | Due to darwin gcc bug, one version of darwin linker coalesces static const int, which defauts PassID based pass identification. llvm-svn: 36652
* Do not use typeinfo to identify pass in pass manager.Devang Patel2007-05-011-0/+2
| | | | llvm-svn: 36632
* Moved from include/llvm/CodeGen to lib/CodeGen.Bill Wendling2007-02-081-0/+226
llvm-svn: 34027
OpenPOWER on IntegriCloud