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
Rafael Espindola
8c4963712f Convert MachOObjectFile to a template.
For now it is templated only on being 64 or 32 bits. I will add little/big
endian next.

llvm-svn: 179097
2013-04-09 14:49:08 +00:00
Rafael Espindola
99aef06cd8 More uses for SymbolTableEntryBase.
llvm-svn: 179076
2013-04-09 01:04:06 +00:00
Rafael Espindola
18c6f4c1eb Add a SymbolTableEntryBase.
Use it when we don't need to know if we have a 32 or 64 bit SymbolTableEntry.

llvm-svn: 179074
2013-04-09 00:22:58 +00:00
Rafael Espindola
f3e0e85032 Add a SectionBase struct.
Use it to share code and when we don't need to know if we have a 32 or 64
bit Section.

llvm-svn: 179072
2013-04-08 23:57:13 +00:00
Rafael Espindola
ad3e40ef0b Template the MachO types over the word size.
llvm-svn: 179051
2013-04-08 20:45:01 +00:00
Rafael Espindola
c6bdeafc97 Remove is64BitLoadCommand.
llvm-svn: 179048
2013-04-08 20:18:53 +00:00
Rafael Espindola
3af5b962c2 Add all 4 MachO object types. Use the stored type to implement is64Bits().
llvm-svn: 179021
2013-04-08 13:25:33 +00:00
Rafael Espindola
e56e7eefd9 Make MachOObjectFile independent from MachOObject.
llvm-svn: 178998
2013-04-07 20:01:29 +00:00
Rafael Espindola
dc06745581 Implement MachOObjectFile::getData directly.
llvm-svn: 178997
2013-04-07 19:42:15 +00:00
Rafael Espindola
6e5f665040 Implement MachOObjectFile::is64Bit directly.
llvm-svn: 178996
2013-04-07 19:38:15 +00:00
Rafael Espindola
f3433150f0 Implement MachOObjectFile::getHeaderSize directly.
llvm-svn: 178995
2013-04-07 19:31:49 +00:00
Rafael Espindola
9e1ac1d494 Implement MachOObjectFile::getHeader directly.
llvm-svn: 178994
2013-04-07 19:26:57 +00:00
Rafael Espindola
80c526beb4 Implement MachOObjectFile::getHeaderSize and MachOObjectFile::getData.
These were the last missing forwarding functions. Also consistently use
the forwarding functions instead of using MachOObj directly.

llvm-svn: 178992
2013-04-07 19:05:30 +00:00
Rafael Espindola
583b0c9980 Remove LoadCommandInfo now that we always have a pointer to the command.
LoadCommandInfo was needed to keep a command and its offset in the file. Now
that we always have a pointer to the command, we don't need the offset.

llvm-svn: 178991
2013-04-07 18:42:06 +00:00
Rafael Espindola
d0f09e97b6 Add MachOObjectFile::LoadCommandInfo.
This avoids using MachOObject::getLoadCommandInfo.

llvm-svn: 178990
2013-04-07 18:08:12 +00:00
Rafael Espindola
1f97d757b6 Use getLoadCommandInfo instead of MachOObj->getLoadCommandInfo.
llvm-svn: 178989
2013-04-07 17:41:59 +00:00
Rafael Espindola
b10740ce9c Construct MachOObject in MachOObjectFile's constructor.
llvm-svn: 178988
2013-04-07 16:58:48 +00:00
Rafael Espindola
5700fcf335 Remove unused argument.
llvm-svn: 178987
2013-04-07 16:40:00 +00:00
Rafael Espindola
fcd60f68e0 Remove MachOObjectFile::getObject.
llvm-svn: 178986
2013-04-07 16:07:35 +00:00
Rafael Espindola
04cc447824 Remove two uses of getObject.
llvm-svn: 178985
2013-04-07 15:46:05 +00:00
Rafael Espindola
c5166cdd27 Remove last use of InMemoryStruct in llvm-objdump.
llvm-svn: 178979
2013-04-07 14:40:18 +00:00
Rafael Espindola
16b282f950 Remove last use of InMemoryStruct from MachOObjectFile.cpp.
llvm-svn: 178948
2013-04-06 03:50:05 +00:00
Rafael Espindola
36d9a8ee5a Don't use InMemoryStruct<macho::SymtabLoadCommand>.
This also required not using the RegisterStringTable API, which is also a
good thing.

llvm-svn: 178947
2013-04-06 03:31:08 +00:00
Rafael Espindola
10cfc91e30 Don't use InMemoryStruct in getSymbol64TableEntry.
llvm-svn: 178946
2013-04-06 02:15:44 +00:00
Rafael Espindola
9908b158ea Don't use InMemoryStruct in getSymbolTableEntry.
llvm-svn: 178945
2013-04-06 01:59:05 +00:00
Rafael Espindola
328a4f48c4 Don't use InMemoryStruct in getRelocation.
llvm-svn: 178943
2013-04-06 01:24:11 +00:00
Rafael Espindola
804fd781f1 Define versions of Section that are explicitly marked as little endian.
These should really be templated like ELF, but this is a start.

llvm-svn: 178896
2013-04-05 18:45:28 +00:00
Rafael Espindola
77ac879d96 Don't use InMemoryStruct in getSection and getSection64.
llvm-svn: 178894
2013-04-05 18:18:19 +00:00
Rafael Espindola
79787bd764 Don't fetch pointers from a InMemoryStruct.
InMemoryStruct is extremely dangerous as it returns data from an internal
buffer when the endiannes doesn't match. This should fix the tests on big
endian hosts.

llvm-svn: 178875
2013-04-05 15:15:22 +00:00
Eric Christopher
ac2a8f05d2 Move an assert earlier in a file and check that the result of
our bitwise compare is equal to the field we're looking for.

Noticed on inspection.

llvm-svn: 176296
2013-02-28 20:26:17 +00:00
Guy Benyei
92dac48079 Add static cast to unsigned char whenever a character classification function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration.
llvm-svn: 175006
2013-02-12 21:21:59 +00:00
Michael J. Spencer
5c9c5547e6 [Object][Archive] Improve performance.
Improve performance of iterating over children and accessing the member file
buffer by caching the file size and moving code out to the header.

This also makes getBuffer return a StringRef instead of a MemoryBuffer. Both
fixing a memory leak and removing a malloc.

This takes getBuffer from ~10% of the time in lld to unmeasurable.

llvm-svn: 174272
2013-02-03 10:48:50 +00:00
Michael J. Spencer
2eb480f731 [Support] Add LLVM_IS_UNALIGNED_ACCESS_FAST.
llvm-svn: 174271
2013-02-03 10:48:31 +00:00
Jim Grosbach
3ea2e57843 Object: Fix errant fallthrough.
llvm-svn: 174079
2013-01-31 19:46:57 +00:00
Eli Bendersky
87e2fa1583 When encountering an unknown file format, ObjectFile::createObjectFile should
politely report it instead of running into llvm_unreachable.

Also patch llvm-dwarfdump to actually check whether the file it's attempting to
dump is a valid object file.

llvm-svn: 173489
2013-01-25 20:53:41 +00:00
Daniel Dunbar
1cb39fe210 [MC/Mach-O] Add support for linker options in Mach-O files.
llvm-svn: 172779
2013-01-18 01:26:07 +00:00
Michael J. Spencer
265466c97e [Object][ELF] Simplify ELFObjectFile by using ELFType.
This simplifies the usage and implementation of ELFObjectFile by using ELFType
to replace:

<endianness target_endianness, std::size_t max_alignment, bool is64Bits>

This does complicate the base ELF types as they must now use template template
parameters to partially specialize for the 32 and 64bit cases. However these
are only defined once.

llvm-svn: 172515
2013-01-15 07:44:25 +00:00
David Greene
0f0e064b65 Fix More Casts
Fix another cast-away-const cast.

llvm-svn: 172466
2013-01-14 21:04:38 +00:00
Michael J. Spencer
73b10e00ef [Object][Archive] Fix name handling with bsd style long names.
llvm-svn: 172026
2013-01-10 01:05:34 +00:00
Michael J. Spencer
ef497c3bba [Object][Archive] Apparently StringRef::getAsInteger for APInt accepts spaces.
llvm-svn: 172022
2013-01-10 00:07:38 +00:00
Michael J. Spencer
1ef7ed2a3d [Object][Archive] Use uint64_t instead of APInt. It is significantly faster.
llvm-svn: 172015
2013-01-09 22:58:43 +00:00
Michael J. Spencer
641cf62d29 [Object][ELF] Add a maximum alignment. This is used by createELFObjectFile to create a properly aligned reader.
llvm-svn: 171520
2013-01-04 20:36:28 +00:00
Rafael Espindola
cca2985848 Add a function to get the segment name of a section.
On MachO, sections also have segment names. When a tool looking at a .o file
prints a segment name, this is what they mean. In reality, a .o has only one
anonymous, segment.

This patch adds a MachO only function to fetch that segment name. I named it
getSectionFinalSegmentName since the main use for the name seems to be inform
the linker with segment this section should go to.

The patch also changes MachOObjectFile::getSectionName to return just the
section name instead of computing SegmentName,SectionName.

The main difference from the previous patch is that it doesn't use
InMemoryStruct. It is extremely dangerous: if the endians match it returns
a pointer to the file buffer, if not, it returns a pointer to an internal buffer
that is overwritten in the next API call.

We should change all of this code to use
support::detail::packed_endian_specific_integral like ELF, but since these
functions only handle strings, they work with big and little endian machines
as is.

I have tested this by installing ubuntu 12.10 ppc on qemu, that is why it took
so long :-)

llvm-svn: 170838
2012-12-21 03:47:03 +00:00
Rafael Espindola
e919c7cf9e Revert 170545 while I debug the ppc failures.
llvm-svn: 170547
2012-12-19 14:48:05 +00:00
Rafael Espindola
f95d54b477 Add r170095 back.
I cannot reproduce it the failures locally, so I will keep an eye at the ppc
bots. This patch does add the change to the "Disassembly of section" message,
but that is not what was failing on the bots.

Original message:

Add a funciton to get the segment name of a section.

On MachO, sections also have segment names. When a tool looking at a .o file
prints a segment name, this is what they mean. In reality, a .o has only one
anonymous, segment.

This patch adds a MachO only function to fetch that segment name. I named it
getSectionFinalSegmentName since the main use for the name seems to be infor
the linker with segment this section should go to.

The patch also changes MachOObjectFile::getSectionName to return just the
section name instead of computing SegmentName,SectionName.

llvm-svn: 170545
2012-12-19 14:15:04 +00:00
Tim Northover
5f7dc099cf Teach MachO which sections contain code
llvm-svn: 170349
2012-12-17 17:59:32 +00:00
Eric Christopher
f555863a16 Revert "Add a funciton to get the segment name of a section."
This reverts commit r170095 since it appears to be breaking the bots.

llvm-svn: 170105
2012-12-13 06:36:18 +00:00
Rafael Espindola
7eb5b9d2f9 Add a funciton to get the segment name of a section.
On MachO, sections also have segment names. When a tool looking at a .o file
prints a segment name, this is what they mean. In reality, a .o has only one,
anonymous, segment.

This patch adds a MachO only function to fetch that segment name. I named it
getSectionFinalSegmentName since the main use for the name seems to be informing
the linker with segment this section should go to.

The patch also changes MachOObjectFile::getSectionName to return just the
section name instead of computing SegmentName,SectionName.

llvm-svn: 170095
2012-12-13 04:07:18 +00:00
Rafael Espindola
a0cba71be8 Remove some dead code.
llvm-svn: 169963
2012-12-12 06:18:15 +00:00
Chandler Carruth
a490793037 Use the new script to sort the includes of every file under lib.
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

llvm-svn: 169131
2012-12-03 16:50:05 +00:00