Commit Graph

193 Commits

Author SHA1 Message Date
Eric Christopher
b3e6b04aea 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176296 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28 20:26:17 +00:00
Guy Benyei
87d0b9ed14 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175006 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-12 21:21:59 +00:00
Michael J. Spencer
0f76e648d8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174272 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-03 10:48:50 +00:00
Michael J. Spencer
d9d2f18775 [Support] Add LLVM_IS_UNALIGNED_ACCESS_FAST.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174271 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-03 10:48:31 +00:00
Jim Grosbach
133f6b8582 Object: Fix errant fallthrough.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174079 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 19:46:57 +00:00
Eli Bendersky
a965baca3c 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173489 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-25 20:53:41 +00:00
Daniel Dunbar
a94c339423 [MC/Mach-O] Add support for linker options in Mach-O files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172779 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 01:26:07 +00:00
Michael J. Spencer
ac97f5ce48 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172515 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-15 07:44:25 +00:00
David Greene
5a80eefdf7 Fix More Casts
Fix another cast-away-const cast.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172466 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 21:04:38 +00:00
Michael J. Spencer
7932c41884 [Object][Archive] Fix name handling with bsd style long names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172026 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10 01:05:34 +00:00
Michael J. Spencer
bf82b07f5f [Object][Archive] Apparently StringRef::getAsInteger for APInt accepts spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172022 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10 00:07:38 +00:00
Michael J. Spencer
e92800dd53 [Object][Archive] Use uint64_t instead of APInt. It is significantly faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172015 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-09 22:58:43 +00:00
Michael J. Spencer
4d9c5397b4 [Object][ELF] Add a maximum alignment. This is used by createELFObjectFile to create a properly aligned reader.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171520 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-04 20:36:28 +00:00
Rafael Espindola
cef81b37c7 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 :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170838 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 03:47:03 +00:00
Rafael Espindola
cd7ee1ced0 Revert 170545 while I debug the ppc failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170547 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-19 14:48:05 +00:00
Rafael Espindola
f9a6bd8524 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170545 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-19 14:15:04 +00:00
Tim Northover
1c2b2f9c56 Teach MachO which sections contain code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170349 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-17 17:59:32 +00:00
Eric Christopher
ef8581479e Revert "Add a funciton to get the segment name of a section."
This reverts commit r170095 since it appears to be breaking the bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170105 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13 06:36:18 +00:00
Rafael Espindola
e3ec87a6f7 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170095 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13 04:07:18 +00:00
Rafael Espindola
9ee68e3f72 Remove some dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169963 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-12 06:18:15 +00:00
Chandler Carruth
d04a8d4b33 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. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 16:50:05 +00:00
Benjamin Kramer
f56c3e28b9 Object: Pass the buffer name through when making a copy.
Should bring the buildbots back to life.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168935 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-29 20:08:03 +00:00
Jim Grosbach
596e474101 Fix a memory leak in MachOObjectFile.
MachOObjectFile owns a MachOObj, but never frees it. Both MachOObjectFile
and MachOObj want to own the MemoryBuffer, though, so we have to be careful
and give them each one of their own.

Thanks to Greg Clayton, Eric Christopher and Michael Spencer for helping
figure out what's going wrong here.

rdar://12561773

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168923 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-29 19:14:11 +00:00
Matt Beaumont-Gay
7af4b9b33a s/assert/llvm_unreachable/
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167936 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 17:58:11 +00:00
Matt Beaumont-Gay
f1c2a6b512 Fix broken asserts. Also, spell 'indices' correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167894 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 00:21:27 +00:00
Michael J. Spencer
768a707fdf [Object] Fix endianess bug by refactoring Archive::Symbol::getMember.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167893 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 00:04:13 +00:00
Shankar Easwaran
206252cc9f Adding changes to support GNU style archive library reading
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167853 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 18:38:42 +00:00
Tim Northover
a41dce3c64 Add interface for querying object files for symbol values.
Currently only implemented for ELF.

Patch by Amara Emerson.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166918 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29 10:47:00 +00:00
Andrew Kaylor
30b20ebdd3 Cosmetic changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165588 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-10 01:45:52 +00:00
Andrew Kaylor
3a129c8592 This patch adds new functions to the SectionRef and ObjectFile interfaces to determine whether or not a section is meant to be read-only. These functions will be used by the MCJIT RuntimeDyld to give hints to the memory manager during the object loading process in a future patch.
Patch by Ashok Thirumurthi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165586 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-10 01:41:33 +00:00
Galina Kistanova
7f5714f439 Reverting r 160419.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160525 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-19 21:43:55 +00:00
Galina Kistanova
d3a32b952b Fixed few warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160419 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-18 04:06:49 +00:00
Marshall Clow
9ac0f1d725 Added accessors for getting coff_relocation info
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158675 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 19:47:16 +00:00
Marshall Clow
45aad162c6 Had a closing brace inside an #ifdef -- oops!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158485 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 01:15:47 +00:00
Marshall Clow
d4d03e09d3 Adding acessors to COFFObjectFile so that clients can get at the (non-generic) bits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158484 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 01:08:25 +00:00
Dmitri Gribenko
77592fe39c Convert comments to proper Doxygen comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158248 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-09 00:01:45 +00:00
Craig Topper
e329810482 Mark some static arrays as const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157377 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 06:35:32 +00:00
Jim Grosbach
3e96531186 Refactor data-in-code annotations.
Use a dedicated MachO load command to annotate data-in-code regions.
This is the same format the linker produces for final executable images,
allowing consistency of representation and use of introspection tools
for both object and executable files.

Data-in-code regions are annotated via ".data_region"/".end_data_region"
directive pairs, with an optional region type.

data_region_directive := ".data_region" { region_type }
region_type := "jt8" | "jt16" | "jt32" | "jta32"
end_data_region_directive := ".end_data_region"

The previous handling of ARM-style "$d.*" labels was broken and has
been removed. Specifically, it didn't handle ARM vs. Thumb mode when
marking the end of the section.

rdar://11459456

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157062 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-18 19:12:01 +00:00
Eli Friedman
41827f9ba2 Fix the implementation of MachOObjectFile::isSectionZeroInit so it follows the MachO spec.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155976 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 02:31:28 +00:00
Preston Gurd
689ff9c00f Implement GDB integration for source level debugging of code JITed using
the MCJIT execution engine.

The GDB JIT debugging integration support works by registering a loaded
object image with a pre-defined function that GDB will monitor if GDB
is attached. GDB integration support is implemented for ELF only at this
time. This integration requires GDB version 7.0 or newer.

Patch by Andy Kaylor!

 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154868 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 22:12:58 +00:00
Benjamin Kramer
8fc7d5c35c Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154661 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-13 08:09:12 +00:00
Preston Gurd
c68dda815e This patch improves the MCJIT runtime dynamic loader by adding new handling
of zero-initialized sections, virtual sections and common symbols
and preventing the loading of sections which are not required for
execution such as debug information.

Patch by Andy Kaylor!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154610 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-12 20:13:57 +00:00
Danil Malyshev
3fd9b84223 Add a constructor for DataRefImpl and remove excess initialization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154371 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-10 01:54:44 +00:00
Dylan Noblesmith
70debecde6 Object: drop bogus VMCore dependency
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153956 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-03 15:48:10 +00:00
Michael J. Spencer
1f6e3f9544 [Object/COFF]: Expose getSectionContents.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153051 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-19 20:27:37 +00:00
Michael J. Spencer
b35a896e07 [Object/COFF]: Expose getSectionName.
Also add some documentation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153050 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-19 20:27:15 +00:00
Michael J. Spencer
33a1805f35 Fix bug found by warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152812 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 17:49:29 +00:00
David Meyer
6f9489a86f [Object]
Make Binary::TypeID more granular, to distinguish between ELF 32/64 little/big




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152435 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 20:41:57 +00:00
David Meyer
97f7787bfb [Object]
Add ObjectFile::getLoadName() for retrieving the soname/installname of a shared object.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151845 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 22:19:54 +00:00
David Meyer
5c2b4ea73c [Object]
* Add begin_dynamic_table() / end_dynamic_table() private interface to ELFObjectFile.
* Add begin_libraries_needed() / end_libraries_needed() interface to ObjectFile, for grabbing the list of needed libraries for a shared object or dynamic executable.
* Implement this new interface completely for ELF, leave stubs for COFF and MachO.
* Add 'llvm-readobj' tool for dumping ObjectFile information.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151785 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 01:36:50 +00:00