Commit Graph

86 Commits

Author SHA1 Message Date
Michael J. Spencer
63b2f8c710 ELF: Fix the section that relocations apply to. Add test to verify. Patch by Danil Malyshev!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141901 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-13 22:30:10 +00:00
Michael J. Spencer
bff6f8679a COFF: Implement sectionContainsSymbol for relocatable files only.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141884 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-13 20:36:54 +00:00
Nick Lewycky
f77dea13d7 Elf_Word is not POD! Stop using it in a DenseMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-13 03:30:21 +00:00
Owen Anderson
95f8db4d4d The VMAs stored in the symbol table of a MachO file are absolute addresses, not offsets from the section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141828 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 22:37:10 +00:00
Owen Anderson
10a8c62d46 Don't label a STAB debugging symbol as a function symbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141824 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 22:23:12 +00:00
Owen Anderson
cd74988fb9 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141822 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 22:21:32 +00:00
Owen Anderson
41242942fc Section indices in MachO symbol tables begin at 1, not 0.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 21:43:24 +00:00
NAKAMURA Takumi
18dcb87f6b 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141774 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 10:28:55 +00:00
Owen Anderson
f7c93a3867 Expose MachOObjectFile externally, like we do for COFF. First step in reducing the amount of special-purpose code needed for llvm-objdump.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141684 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 17:32:27 +00:00
Nick Lewycky
bfbbe32837 Reapply r141605 with fixes for appropriate handling of reserved section numbers
in st_shndx fields.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141639 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 03:18:58 +00:00
Nick Lewycky
15c3f727ae Add support for .symtab_shnidx. Unfortunately, doing this required breaking a
layer of abstraction around SymbolRef where you can read its private
SymbolPimpl member.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141636 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 02:57:48 +00:00
Nick Lewycky
fb05d3d686 Revert r141605 as it broke tests for llvm-nm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141614 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 00:38:56 +00:00
Nick Lewycky
fad138dd79 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141605 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 00:15:42 +00:00
Michael J. Spencer
15565ad758 Fix warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141597 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-10 23:36:56 +00:00
Michael J. Spencer
e2f2f07be7 Object: add getSectionAlignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141581 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-10 21:55:43 +00:00
NAKAMURA Takumi
48f248ad5f lib/Object: Suppress warnings on gcc-4.3.4 cygwin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141485 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-08 11:22:53 +00:00
Michael J. Spencer
c6500a5d77 Object: Add support for opening stdin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141449 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-08 00:17:58 +00:00
Michael J. Spencer
5861893c25 Object: constize Archive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141448 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-08 00:17:45 +00:00
Michael J. Spencer
01a4db3ed4 Fix GCC again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141389 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 19:46:12 +00:00
Michael J. Spencer
4344b1ef9b Change relocation API to be per section. This time without breaking GCC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141385 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 19:25:32 +00:00
Bill Wendling
a48ad13339 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141379 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 18:25:37 +00:00
Michael J. Spencer
f1164a2487 Change relocation API to be per section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 18:15:25 +00:00
Michael J. Spencer
13afc5eff2 Object: Add isSection{Data,BSS}.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140721 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-28 20:57:30 +00:00
Michael J. Spencer
a51d7d97b0 Object: Add archive support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140626 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 19:36:55 +00:00
Benjamin Kramer
ac241fe9f0 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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139683 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 01:22:52 +00:00
Benjamin Kramer
836623420d ObjectFile: Add support for mach-o-style dSYM companion files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139676 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 00:39:22 +00:00
Benjamin Kramer
cee58a69fa Silence false positive uninitialized variable warnings from GCC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139573 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 01:59:24 +00:00
Benjamin Kramer
d40b0b0a06 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139343 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 00:22:05 +00:00
Nick Lewycky
58856eae16 Fix release build:
MachOObjectFile.cpp:524: error: unused variable 'NumLoadCommands' [-Wunused-variable]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139341 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 00:16:50 +00:00
Benjamin Kramer
0fcab076f0 Add support for relocations to ObjectFile.
Patch by Danil Malyshev!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 20:52:17 +00:00
Benjamin Kramer
d4522460d4 Teach macho-dump to dump the uleb128s referred to by linkedit_data segments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138836 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 22:10:58 +00:00
Benjamin Kramer
9942acab0a Teach macho-dump how to dump linkedit_data load commands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138807 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 18:33:37 +00:00
Chandler Carruth
ac03e736c7 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136433 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:14:25 +00:00
Benjamin Kramer
07ea23aa2d 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135288 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 18:39:21 +00:00
Benjamin Kramer
32fb2af679 MachOObjectFile: Get symbol functions ready for 64 bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135282 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 17:32:45 +00:00
Benjamin Kramer
291e767dcf Output MachO section names in the form SEGMENT,section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135231 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 00:29:02 +00:00
Benjamin Kramer
7d145789c0 Add support for 64 bit objects to MachOObjectFile.
- I don't see a better way than duplicating all the code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135229 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 00:14:48 +00:00
Benjamin Kramer
82ba5b7c40 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)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135228 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 00:14:46 +00:00
Benjamin Kramer
3209a03daf Use memcmp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134439 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 20:28:00 +00:00
Rafael Espindola
9b9c5ea2c3 Really fix typo :-(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134436 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 19:17:10 +00:00
Rafael Espindola
5ac795c56f Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134433 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 19:13:27 +00:00
Rafael Espindola
82c475d057 Compare all 4 bytes of the header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134427 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 18:41:47 +00:00
Michael J. Spencer
64388ceee0 Fix warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134408 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 14:48:59 +00:00
Michael J. Spencer
25b15777df Object: Add proper error handling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 17:55:23 +00:00
Michael J. Spencer
001c9205fc Make Binary the parent of ObjectFile and update children to new interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133870 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 17:54:50 +00:00
Michael J. Spencer
c44c915372 Add Binary class. This is a cleaner parent than ObjectFile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133869 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 17:54:29 +00:00
Michael J. Spencer
d2a02f409e Add Object/Error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133868 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 17:42:56 +00:00
Benjamin Kramer
aa99bea46f Revert r132910 and r132909 on behalf of Michael. They didn't build with clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132914 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 12:56:51 +00:00
Michael J. Spencer
5e45dc40d3 Revert the last two commits in the series. r132911, r132912.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132913 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 11:53:31 +00:00
Michael J. Spencer
69aec36f9b Make Binary the parent of ObjectFile and update children to new interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132911 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 11:12:33 +00:00