1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

222 Commits

Author SHA1 Message Date
Benjamin Kramer
a05d5433f5 MachOObject: Use DataExtractor's uleb parser instead of rolling our own.
llvm-svn: 143810
2011-11-05 12:13:21 +00:00
Benjamin Kramer
26ed5d6390 Simplify code.
llvm-svn: 143695
2011-11-04 13:52:17 +00:00
Daniel Dunbar
3760ebeebb build: Add initial cut at LLVMBuild.txt files.
llvm-svn: 143634
2011-11-03 18:53:17 +00:00
Chad Rosier
8a1a2adbb7 Removed unused variable.
llvm-svn: 143591
2011-11-02 23:21:55 +00:00
Michael J. Spencer
7dcaa63cb2 object/COFF: Properly initalize uses of DataRefImpl.
llvm-svn: 143562
2011-11-02 19:33:26 +00:00
Michael J. Spencer
c059c6c5b9 Object/Archive: Add symbol table iteration.
llvm-svn: 143561
2011-11-02 19:33:12 +00:00
Owen Anderson
6508cba44c If we're searching for a symbol reference to pretty-print a scattered relocation address, and we don't find a symbol table entry, try section begin addresses as well.
llvm-svn: 143151
2011-10-27 21:53:50 +00:00
Owen Anderson
9aaee13bf1 Fix pretty printing of i386 local sect diff relocations, TLV relocations, and x86_64 TLV relocations in MachO.
llvm-svn: 143140
2011-10-27 20:46:09 +00:00
Owen Anderson
997d323baa Expose relocation accessors through the libObject C API.
llvm-svn: 143109
2011-10-27 17:32:36 +00:00
Owen Anderson
ece66e91f2 Add relocation iterators to the libObject C API.
llvm-svn: 143107
2011-10-27 17:15:47 +00:00
Owen Anderson
11396b575d Add support for scattered relocations to the MachO relocatation pretty printer.
llvm-svn: 143051
2011-10-26 20:42:54 +00:00
Owen Anderson
8d9656dd53 The order of the two symbol listings in a Macho x86_64 subtractor relocation is reversed from what seems intuitive to me.
llvm-svn: 143035
2011-10-26 17:28:49 +00:00
Owen Anderson
27580bf1eb Include the full 64 bits of relocation data in the type info for MachO relocations, so that we can recognize scattered relocations.
llvm-svn: 143033
2011-10-26 17:10:22 +00:00
Owen Anderson
7a9bb4d47f Expand relocation type field to 64 bits. MachO scattered relocations require 33 bits of type info.
llvm-svn: 143032
2011-10-26 17:08:49 +00:00
Owen Anderson
fc7467fd5e Improve pretty printing of GOT relocations in MachO on x86_64.
llvm-svn: 143031
2011-10-26 17:05:20 +00:00
Eric Christopher
0042cece21 Remove unused variable.
llvm-svn: 143011
2011-10-26 03:47:16 +00:00
Michael J. Spencer
03ffc01ea6 Object/Archive: Cleanup anon namespace.
llvm-svn: 142983
2011-10-25 22:31:11 +00:00
Michael J. Spencer
6f6b8f7b4d Object/Archive: Add BSD style long file name support and skip internal members.
llvm-svn: 142981
2011-10-25 22:30:42 +00:00
Owen Anderson
b3538ebf33 Remove extraneous printing of "-PC".
llvm-svn: 142970
2011-10-25 20:44:00 +00:00
Owen Anderson
69d98376b9 Add support for the notion of "hidden" relocations. On MachO, these are relocation entries that are used as additional information for other, real relocations, rather than being relocations themselves.
I'm not familiar enough with ELF or COFF to know if they should have any relocations marked hidden.

llvm-svn: 142961
2011-10-25 20:35:53 +00:00
Owen Anderson
60bbbbced1 Teach the MachO relocation pretty-printer to interpret ARM half-relocations.
llvm-svn: 142938
2011-10-25 18:48:41 +00:00
Owen Anderson
3bfe29265a More fixes and improvements to MachO relocation pretty-printing, particular for x86 and x86_64 relocations with addends.
llvm-svn: 142875
2011-10-24 23:20:07 +00:00
Owen Anderson
aa91e360eb Get relocation parsing/dumping to a mostly-working state for MachO files.
llvm-svn: 142852
2011-10-24 21:44:00 +00:00
Owen Anderson
445fdc6049 Stub out some of the MachO relocation decoding hooks.
llvm-svn: 142840
2011-10-24 20:19:18 +00:00
Owen Anderson
0d40d283e9 Use LLVMBool for a function that logically returns a boolean value.
llvm-svn: 142683
2011-10-21 20:35:58 +00:00
Owen Anderson
806a1e5c78 STABS symbols are debug symbols.
llvm-svn: 142673
2011-10-21 19:26:54 +00:00
Owen Anderson
da28398bb6 Bind libObject API for obtaining the section containing a Symbol.
llvm-svn: 142667
2011-10-21 18:21:22 +00:00
Owen Anderson
33b5868dab Expand the coverage of the libObject C bindings to include more SectionRef accessors as well as Symbol iterators.
llvm-svn: 142661
2011-10-21 17:50:59 +00:00
Michael J. Spencer
1b471da6b0 Object/COFF: Remove useless test.
llvm-svn: 142408
2011-10-18 19:51:36 +00:00
Michael J. Spencer
cdfd6ee8bc Object/COFF: Change type from a struct to a uint16_t. The struct would be
incorrect for bigendian systems.

llvm-svn: 142403
2011-10-18 19:31:59 +00:00
Michael J. Spencer
adc33b805a Object: Add some types to SymbolRef::Type.
Some of these can be true at the same time and there are a lot to add,
so this should be turned into a bitfield. Some of the other accessors
should probably be folded into this.

llvm-svn: 142318
2011-10-17 23:55:06 +00:00
Michael J. Spencer
25b0873d7f Object: Add isSymbolAbsolute and getSymbolSection.
llvm-svn: 142317
2011-10-17 23:54:46 +00:00
Michael J. Spencer
3f458c5498 Object: Add isSymbolWeak.
llvm-svn: 142316
2011-10-17 23:54:22 +00:00
Michael J. Spencer
a9bbb5d675 Object/COFF: Expose more data in the public API.
llvm-svn: 142315
2011-10-17 23:53:56 +00:00
Michael J. Spencer
3a7d4d9fe0 Object: Implement casting for concrete classes.
llvm-svn: 142314
2011-10-17 23:53:37 +00:00
Michael J. Spencer
c787cb4441 Object: Fix redundant name.
llvm-svn: 142238
2011-10-17 20:19:29 +00:00
Michael J. Spencer
10caa055b0 ELF: Fix the section that relocations apply to. Add test to verify. Patch by Danil Malyshev!
llvm-svn: 141901
2011-10-13 22:30:10 +00:00
Michael J. Spencer
9a10012151 COFF: Implement sectionContainsSymbol for relocatable files only.
llvm-svn: 141884
2011-10-13 20:36:54 +00:00
Nick Lewycky
70cfa65b6b Elf_Word is not POD! Stop using it in a DenseMap.
llvm-svn: 141851
2011-10-13 03:30:21 +00:00
Owen Anderson
a3ffb86b9a The VMAs stored in the symbol table of a MachO file are absolute addresses, not offsets from the section.
llvm-svn: 141828
2011-10-12 22:37:10 +00:00
Owen Anderson
6931df0d99 Don't label a STAB debugging symbol as a function symbol.
llvm-svn: 141824
2011-10-12 22:23:12 +00:00
Owen Anderson
6e41e4318d sectionContainsSymbol needs to be based on VMA's rather than section indices to properly account for files with segment load commands that contain no sections.
llvm-svn: 141822
2011-10-12 22:21:32 +00:00
Owen Anderson
43ef26d840 Section indices in MachO symbol tables begin at 1, not 0.
llvm-svn: 141815
2011-10-12 21:43:24 +00:00
NAKAMURA Takumi
35b6744077 lib/Object/ELFObjectFile.cpp: Fix undefined behavior for MC/ELF/many-section.s not to fail (on msvc).
DenseMap::lookup(k) would return "default constructor value" when k was not met. It would be useless when value type were POD.

llvm-svn: 141774
2011-10-12 10:28:55 +00:00
Owen Anderson
85292f7b5d Expose MachOObjectFile externally, like we do for COFF. First step in reducing the amount of special-purpose code needed for llvm-objdump.
llvm-svn: 141684
2011-10-11 17:32:27 +00:00
Nick Lewycky
7cea83d5a5 Reapply r141605 with fixes for appropriate handling of reserved section numbers
in st_shndx fields.

llvm-svn: 141639
2011-10-11 03:18:58 +00:00
Nick Lewycky
c8160ebc71 Add support for .symtab_shnidx. Unfortunately, doing this required breaking a
layer of abstraction around SymbolRef where you can read its private
SymbolPimpl member.

llvm-svn: 141636
2011-10-11 02:57:48 +00:00
Nick Lewycky
76c927f5bd Revert r141605 as it broke tests for llvm-nm.
llvm-svn: 141614
2011-10-11 00:38:56 +00:00
Nick Lewycky
bf9a3771b7 Add support for reading many-section ELF files.
If you want to tackle adding the testcase, let me know. It's a 4.2MB ELF file
and I'll be happy to mail it to you.

llvm-svn: 141605
2011-10-11 00:15:42 +00:00
Michael J. Spencer
525906b5d9 Fix warning.
llvm-svn: 141597
2011-10-10 23:36:56 +00:00
Michael J. Spencer
ebd507f958 Object: add getSectionAlignment.
llvm-svn: 141581
2011-10-10 21:55:43 +00:00
NAKAMURA Takumi
2a3eab692a lib/Object: Suppress warnings on gcc-4.3.4 cygwin
llvm-svn: 141485
2011-10-08 11:22:53 +00:00
Michael J. Spencer
edcc61ba22 Object: Add support for opening stdin.
llvm-svn: 141449
2011-10-08 00:17:58 +00:00
Michael J. Spencer
1acd078990 Object: constize Archive.
llvm-svn: 141448
2011-10-08 00:17:45 +00:00
Michael J. Spencer
3cc26e4c5e Fix GCC again.
llvm-svn: 141389
2011-10-07 19:46:12 +00:00
Michael J. Spencer
34d76cf95b Change relocation API to be per section. This time without breaking GCC.
llvm-svn: 141385
2011-10-07 19:25:32 +00:00
Bill Wendling
ecbddb2b9e Revert 141376 and 141377 due to breaking the build.
--- Reverse-merging r141377 into '.':
U    tools/llvm-objdump/MachODump.cpp
--- Reverse-merging r141376 into '.':
U    include/llvm/Object/COFF.h
U    include/llvm/Object/ObjectFile.h
U    include/llvm-c/Object.h
U    tools/llvm-objdump/llvm-objdump.cpp
U    lib/Object/MachOObjectFile.cpp
U    lib/Object/COFFObjectFile.cpp
U    lib/Object/Object.cpp
U    lib/Object/ELFObjectFile.cpp

llvm-svn: 141379
2011-10-07 18:25:37 +00:00
Michael J. Spencer
14925a859b Change relocation API to be per section.
llvm-svn: 141376
2011-10-07 18:15:25 +00:00
Michael J. Spencer
5948c3822e Object: Add isSection{Data,BSS}.
llvm-svn: 140721
2011-09-28 20:57:30 +00:00
Michael J. Spencer
82f9fa9d9a Object: Add archive support.
llvm-svn: 140626
2011-09-27 19:36:55 +00:00
Benjamin Kramer
52607b3842 Object: make the following changes into SymbolRef
- Add enum SymbolType and function getSymbolType()
- Add function isGlobal() - it's returns true for symbols that can be used in another objects, such as library functions.
- Rename function getAddress() to getOffset() and add new function getAddress(), because currently getAddress() returns section offset of symbol first byte. new getAddress() return symbol address.
- Change usage SymbolRef::getAddress() to getOffset() in tools/llvm-nm and tools/llvm-objdump.

Patch by Danil Malyshev!

llvm-svn: 139683
2011-09-14 01:22:52 +00:00
Benjamin Kramer
5b94d9657f ObjectFile: Add support for mach-o-style dSYM companion files.
llvm-svn: 139676
2011-09-14 00:39:22 +00:00
Benjamin Kramer
b101f55fa4 Silence false positive uninitialized variable warnings from GCC.
llvm-svn: 139573
2011-09-13 01:59:24 +00:00
Benjamin Kramer
da0ca686c9 Remove dead code.
llvm-svn: 139343
2011-09-09 00:22:05 +00:00
Nick Lewycky
ec5437bfc4 Fix release build:
MachOObjectFile.cpp:524: error: unused variable 'NumLoadCommands' [-Wunused-variable]

llvm-svn: 139341
2011-09-09 00:16:50 +00:00
Benjamin Kramer
3c40c2100b Add support for relocations to ObjectFile.
Patch by Danil Malyshev!

llvm-svn: 139314
2011-09-08 20:52:17 +00:00
Benjamin Kramer
2ca7c2b2c7 Teach macho-dump to dump the uleb128s referred to by linkedit_data segments.
llvm-svn: 138836
2011-08-30 22:10:58 +00:00
Benjamin Kramer
de3a6db63c Teach macho-dump how to dump linkedit_data load commands.
llvm-svn: 138807
2011-08-30 18:33:37 +00:00
Chandler Carruth
f7890e34b9 Rewrite the CMake build to use explicit dependencies between libraries,
specified in the same file that the library itself is created. This is
more idiomatic for CMake builds, and also allows us to correctly specify
dependencies that are missed due to bugs in the GenLibDeps perl script,
or change from compiler to compiler. On Linux, this returns CMake to
a place where it can relably rebuild several targets of LLVM.

I have tried not to change the dependencies from the ones in the current
auto-generated file. The only places I've really diverged are in places
where I was seeing link failures, and added a dependency. The goal of
this patch is not to start changing the dependencies, merely to move
them into the correct location, and an explicit form that we can control
and change when necessary.

This also removes a serialization point in the build because we don't
have to scan all the libraries before we begin building various tools.
We no longer have a step of the build that regenerates a file inside the
source tree. A few other associated cleanups fall out of this.

This isn't really finished yet though. After talking to dgregor he urged
switching to a single CMake macro to construct libraries with both
sources and dependencies in the arguments. Migrating from the two macros
to that style will be a follow-up patch.

Also, llvm-config is still generated with GenLibDeps.pl, which means it
still has slightly buggy dependencies. The internal CMake
'llvm-config-like' macro uses the correct explicitly specified
dependencies however. A future patch will switch llvm-config generation
(when using CMake) to be based on these deps as well.

This may well break Windows. I'm getting a machine set up now to dig
into any failures there. If anyone can chime in with problems they see
or ideas of how to solve them for Windows, much appreciated.

llvm-svn: 136433
2011-07-29 00:14:25 +00:00
Benjamin Kramer
5936e08079 ObjectFile: Add a method to check whether a section contains a symbol.
- No ELF or COFF implementation yet, I don't have a way to test that.
  Should be straightforward to add though.

llvm-svn: 135288
2011-07-15 18:39:21 +00:00
Benjamin Kramer
3a3a5a7f5e MachOObjectFile: Get symbol functions ready for 64 bit.
llvm-svn: 135282
2011-07-15 17:32:45 +00:00
Benjamin Kramer
5365237e2e Output MachO section names in the form SEGMENT,section.
llvm-svn: 135231
2011-07-15 00:29:02 +00:00
Benjamin Kramer
4ab7b03d14 Add support for 64 bit objects to MachOObjectFile.
- I don't see a better way than duplicating all the code.

llvm-svn: 135229
2011-07-15 00:14:48 +00:00
Benjamin Kramer
3622333b55 MachOObjectFile: Change isSectionText to return true for sections named text, not for load commands name __TEXT (which isn't the case in actual object files)
llvm-svn: 135228
2011-07-15 00:14:46 +00:00
Benjamin Kramer
b054fe79e3 Use memcmp.
llvm-svn: 134439
2011-07-05 20:28:00 +00:00
Rafael Espindola
9fdf25214f Really fix typo :-(
llvm-svn: 134436
2011-07-05 19:17:10 +00:00
Rafael Espindola
1b99dbcf82 Fix typo.
llvm-svn: 134433
2011-07-05 19:13:27 +00:00
Rafael Espindola
e54f949f37 Compare all 4 bytes of the header.
llvm-svn: 134427
2011-07-05 18:41:47 +00:00
Michael J. Spencer
342a6e8a5f Fix warnings.
llvm-svn: 134408
2011-07-05 14:48:59 +00:00
Michael J. Spencer
83e956656a Object: Add proper error handling.
llvm-svn: 133872
2011-06-25 17:55:23 +00:00
Michael J. Spencer
d5934fefee Make Binary the parent of ObjectFile and update children to new interface.
llvm-svn: 133870
2011-06-25 17:54:50 +00:00
Michael J. Spencer
8cb6d93f56 Add Binary class. This is a cleaner parent than ObjectFile.
llvm-svn: 133869
2011-06-25 17:54:29 +00:00
Michael J. Spencer
435e1ee994 Add Object/Error.
llvm-svn: 133868
2011-06-25 17:42:56 +00:00
Benjamin Kramer
8bd126a5c6 Revert r132910 and r132909 on behalf of Michael. They didn't build with clang.
llvm-svn: 132914
2011-06-13 12:56:51 +00:00
Michael J. Spencer
8288453980 Revert the last two commits in the series. r132911, r132912.
llvm-svn: 132913
2011-06-13 11:53:31 +00:00
Michael J. Spencer
642af05937 Make Binary the parent of ObjectFile and update children to new interface.
llvm-svn: 132911
2011-06-13 11:12:33 +00:00
Michael J. Spencer
bc30ca9794 Add Binary class. This is a cleaner parent than ObjectFile.
llvm-svn: 132910
2011-06-13 11:12:12 +00:00
Michael J. Spencer
d6178b9f59 Add Object/Error.
llvm-svn: 132909
2011-06-13 11:11:59 +00:00
Michael J. Spencer
39a329f72f Fix spelling and sort CMakeLists.txt.
llvm-svn: 132908
2011-06-13 11:11:39 +00:00
Nick Lewycky
c16a030741 Remove dead variable pointed out by GCC 4.6 warnings, and reflow this a little
to scope a variable more tightly per llvm coding style. No functional change.

llvm-svn: 130684
2011-05-02 05:05:29 +00:00
Eric Christopher
dbe03d6412 Use enums for constant values.
llvm-svn: 129984
2011-04-22 06:34:01 +00:00
Eric Christopher
f48677a625 Make the file format strings a little prettier for mach-o.
llvm-svn: 129980
2011-04-22 04:08:58 +00:00
Eric Christopher
c134a52f40 Add MachOObjectFile.cpp to cmake.
llvm-svn: 129978
2011-04-22 04:06:24 +00:00
Eric Christopher
ca7675cd82 Hook in mach-o object files into Object interface.
llvm-svn: 129976
2011-04-22 03:50:50 +00:00
Eric Christopher
f030d7f487 Add an ObjectFile implementation for mach-o.
Patch by Patrick Walton!

llvm-svn: 129974
2011-04-22 03:19:48 +00:00
Eric Christopher
8bfe1d2deb Start migrating mach-o dumping facilities to the object file out of a
separate executable.

llvm-svn: 128801
2011-04-03 23:51:47 +00:00
Eric Christopher
1ed5af1470 Move Object.cpp out of VMCore and into Object.
llvm-svn: 128800
2011-04-03 23:07:51 +00:00
Eric Christopher
0e88a490eb Assorted bugfixes in object file handling:
- Adds support for sniffing PE/COFF files on win32 (.exe and .dll)
   which are COFF files that have an MS-DOS compatibility stub on
   the front of them.

 - Fixes a bug in the COFFObjectFile's support for the Microsoft COFF
   extension for long symbol names, wherein it was attempting to parse
   the leading '/' in an extended symbol name reference as part of the
   integer offset.

 - Fixes bugs in COFFObjectFile and ELFObjectFile wherein section
   and symbol iterators were being returned with uninitialized bytes;
   the type DataRefImpl is a union between 2 32-bit words (d.a and d.b)
   and a single intptr_t word (p). Only p was being initialized, so in
   32-bit builds the result would be iterators with random upper 32-bit
   words in their DataRefImpls. This caused random failures when
   seeking around in object files.

Patch by Graydon Hoare!

llvm-svn: 128799
2011-04-03 22:53:19 +00:00
Michael J. Spencer
e4fe76fa22 Object: Fix type punned pointer issues by making DataRefImpl a union and using intptr_t.
llvm-svn: 123962
2011-01-21 02:27:02 +00:00
Michael J. Spencer
d54bad63f7 Object: Add ELF support.
llvm-svn: 123896
2011-01-20 06:38:47 +00:00
Michael J. Spencer
d4d4ab7712 Object: Add COFF Support.
llvm-svn: 123895
2011-01-20 06:38:34 +00:00
Benjamin Kramer
2203fe28df Fix mismatched new[]/delete.
llvm-svn: 122053
2010-12-17 09:56:50 +00:00
Michael J. Spencer
86f6a9ac6e MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> via an out parm.
llvm-svn: 121958
2010-12-16 03:29:14 +00:00
Daniel Dunbar
fd96efb8e9 Mach-O: Tweak field name.
llvm-svn: 121465
2010-12-10 06:19:39 +00:00
Michael J. Spencer
15483143ec Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.
llvm-svn: 121379
2010-12-09 17:36:48 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Daniel Dunbar
4a5895d6ff macho-dump: Add support for --dump-section-data and tweak a few format strings.
llvm-svn: 120219
2010-11-27 13:58:16 +00:00
Daniel Dunbar
e869ed004c macho-dump: Add support for dumping symbol table entries.
llvm-svn: 120218
2010-11-27 13:52:53 +00:00
Daniel Dunbar
a1e3ba6a1c macho-dump: Add support for dumping string table data.
llvm-svn: 120217
2010-11-27 13:46:11 +00:00
Daniel Dunbar
2dd3ae7c9c macho-dump: Add support for dumping relocation entries.
llvm-svn: 120216
2010-11-27 13:39:48 +00:00
Daniel Dunbar
3aa435a0ac macho-dump: Add support for dumping sections.
llvm-svn: 120215
2010-11-27 13:33:15 +00:00
Daniel Dunbar
2525373652 macho-dump: Add support for dumping dysymtab indirect symbol table.
llvm-svn: 120214
2010-11-27 13:26:12 +00:00
Benjamin Kramer
4d1bd491b0 Unbreak build for newer GCCs.
llvm-svn: 120205
2010-11-27 09:08:25 +00:00
Daniel Dunbar
38307b5ad4 macho-dump: Add support for dumping symtab and dysymtab commands.
llvm-svn: 120204
2010-11-27 08:33:44 +00:00
Daniel Dunbar
44ac81f948 macho-dump: Add support for dumping segment load commands.
llvm-svn: 120203
2010-11-27 08:22:29 +00:00
Daniel Dunbar
9ff2982261 Object/Mach-O: Add header and load command information.
llvm-svn: 120198
2010-11-27 07:19:41 +00:00
Daniel Dunbar
7d054546a8 Object/Mach-O: Validate Mach-O magic and initialize format info.
llvm-svn: 120195
2010-11-27 06:39:22 +00:00
Daniel Dunbar
52f1774650 MC/Mach-O: Start stubbing out a Mach-O object file wrapper.
llvm-svn: 120190
2010-11-27 05:38:50 +00:00
Peter Collingbourne
1cf8df8f83 Fix typo: Exectuable -> Executable
llvm-svn: 119433
2010-11-17 00:43:43 +00:00
Michael J. Spencer
5c5cfac314 Object: Get rid of sys::Path, Triple, and cleanup namespace.
llvm-svn: 119309
2010-11-16 01:06:51 +00:00
Michael J. Spencer
b179ffafea Object: Add missing makefile.
llvm-svn: 119110
2010-11-15 03:33:14 +00:00
Michael J. Spencer
23f31df887 Add LLVMObject Library.
llvm-svn: 119107
2010-11-15 03:21:41 +00:00