History log of /llvm-project/llvm/lib/Object/MachOObjectFile.cpp (Results 76 – 100 of 491)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-10-init, llvmorg-8.0.1, llvmorg-8.0.1-rc4
# 995798d2 04-Jul-2019 Shoaib Meenai <smeenai@fb.com>

[MachO] Add valid architecture function

Added array of valid architectures and function returning array.
Modified llvm-lipo to include list of valid architectures in error message for invalid arch.

[MachO] Add valid architecture function

Added array of valid architectures and function returning array.
Modified llvm-lipo to include list of valid architectures in error message for invalid arch.

Patch by Anusha Basana <anusha.basana@gmail.com>

Differential Revision: https://reviews.llvm.org/D63735

llvm-svn: 365099

show more ...


Revision tags: llvmorg-8.0.1-rc3, llvmorg-8.0.1-rc2
# c3394483 04-Jun-2019 Alex Brachet <alexbrachetmialot@gmail.com>

[MACHO] Replaced calls to getStruct with getStructOrErr in functions returning Error or Expected or similar

llvm-svn: 362526


Revision tags: llvmorg-8.0.1-rc1
# ff6875ac 14-May-2019 Tim Northover <tnorthover@apple.com>

AArch64: support binutils-like things on arm64_32.

This adds support for the arm64_32 watchOS ABI to LLVM's low level tools,
teaching them about the specific MachO choices and constants needed to
di

AArch64: support binutils-like things on arm64_32.

This adds support for the arm64_32 watchOS ABI to LLVM's low level tools,
teaching them about the specific MachO choices and constants needed to
disassemble things.

llvm-svn: 360663

show more ...


# e1cb2c0f 14-May-2019 Fangrui Song <maskray@google.com>

[Object] Change ObjectFile::getSectionContents to return Expected<ArrayRef<uint8_t>>

Change
std::error_code getSectionContents(DataRefImpl, StringRef &) const;
to
Expected<ArrayRef<uint8_t>> getSect

[Object] Change ObjectFile::getSectionContents to return Expected<ArrayRef<uint8_t>>

Change
std::error_code getSectionContents(DataRefImpl, StringRef &) const;
to
Expected<ArrayRef<uint8_t>> getSectionContents(DataRefImpl) const;

Many object formats use ArrayRef<uint8_t> as the underlying type, which
is generally better than StringRef to represent binary data, so change
the type to decrease the number of type conversions.

Reviewed By: ruiu, sbc100

Differential Revision: https://reviews.llvm.org/D61781

llvm-svn: 360648

show more ...


# 8be28cdc 02-May-2019 Fangrui Song <maskray@google.com>

[Object] Change getSectionName() to return Expected<StringRef>

Summary:
It currently receives an output parameter and returns
std::error_code. Expected<StringRef> fits for this purpose perfectly.

D

[Object] Change getSectionName() to return Expected<StringRef>

Summary:
It currently receives an output parameter and returns
std::error_code. Expected<StringRef> fits for this purpose perfectly.

Differential Revision: https://reviews.llvm.org/D61421

llvm-svn: 359774

show more ...


# 4559739f 29-Apr-2019 Simon Pilgrim <llvm-dev@redking.me.uk>

Remove duplicate line. NFCI.

Reported in https://www.viva64.com/en/b/0629/

llvm-svn: 359483


# 02a2ce9a 20-Mar-2019 Michael Trent <mtrent@apple.com>

Fix Mach-O bind and rebase validation errors in libObject

Summary:
llvm-objdump (via libObject) validates DYLD_INFO rebase and bind
entries against the basic structure found in the Mach-O file befor

Fix Mach-O bind and rebase validation errors in libObject

Summary:
llvm-objdump (via libObject) validates DYLD_INFO rebase and bind
entries against the basic structure found in the Mach-O file before
evaluating the contents of those entries. Certain malformed Mach-Os can
defeat the validation check and force llvm-objdump (libObject) to crash.

The previous logic verified a rebase or bind started in a valid Mach-O
section, but did not verify that the section wholely contained the
fixup. It also generally allows rebases or binds to start immediately
after a valid section even if that range is not itself part of a valid
section. Finally, bind and rebase opcodes that indicate more than one
fixup (apply N times...) are not completely validated: only the first
and final fixups are checked.

The previous logic also rejected certain binaries as false positives.
Some bind and rebase opcodes can modify the state machine such that the
next bind or rebase will fail. libObject will reject these opcodes as
invalid in order to be helpful and print an error message associated
with the instruction that caused the problem, even though the binary is
not actually illegal until it consumes the invalid state in the state
machine. In other words, libObject may reject a Mach-O binary that
Apple's dynamic linker may consider legal. The original version of
macho-rebase-add-addr-uleb-too-big is an example of such a binary.

I have replaced the existing checkSegAndOffset and checkCountAndSkip
functions with a single function, checkSegAndOffsets, which validates
all of the fixups realized by a DYLD_INFO opcode. checkSegAndOffsets
verifies that a Mach-O section fully contains each fixup. Every fixup
realized by an opcode is validated, and some (but not all!)
inconsistencies in the state machine are allowed until a fixup is
realized. This means that libObject may fail on an opcode that realizes
a fixup, not on the opcode that introduced the arithmetic error.

Existing test cases have been modified to reflect the changes in error
messages returned by libObject. What's more, the test case for
macho-rebase-add-addr-uleb-too-big has been modified so that it actually
triggers the error condition; the new code in libObject considers the
original test binary "legal".

rdar://47797757

Reviewers: lhames, pete, ab

Reviewed By: pete

Subscribers: rupprecht, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59574

llvm-svn: 356629

show more ...


Revision tags: llvmorg-8.0.0, llvmorg-8.0.0-rc5
# 76d66123 11-Mar-2019 Michael Trent <mtrent@apple.com>

Detect malformed LC_LINKER_COMMANDs in Mach-O binaries

Summary:
llvm-objdump can be tricked into reading beyond valid memory and
segfaulting if LC_LINKER_COMMAND strings are not null terminated. lib

Detect malformed LC_LINKER_COMMANDs in Mach-O binaries

Summary:
llvm-objdump can be tricked into reading beyond valid memory and
segfaulting if LC_LINKER_COMMAND strings are not null terminated. libObject
does have code to validate the integrity of the LC_LINKER_COMMAND struct,
but this validator improperly assumes linker command strings are null
terminated.

The solution is to report an error if a string extends beyond the end of
the LC_LINKER_COMMAND struct.

Reviewers: lhames, pete

Reviewed By: pete

Subscribers: rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59179

llvm-svn: 355851

show more ...


Revision tags: llvmorg-8.0.0-rc4, llvmorg-8.0.0-rc3
# 7dcfac61 23-Feb-2019 Michael Trent <mtrent@apple.com>

objdump fails to parse Mach-O binaries with n_desc bearing stabs

Summary:
The objdump Mach-O parser uses MachOObjectFile::checkSymbolTable() to
verify the symbol table is in a legal state before der

objdump fails to parse Mach-O binaries with n_desc bearing stabs

Summary:
The objdump Mach-O parser uses MachOObjectFile::checkSymbolTable() to
verify the symbol table is in a legal state before dereferencing the
offsets in the table. This routine missed a test for N_STAB symbols
when validating the two-level name space library ordinal for undefined
symbols. If the binary in question contained a value in the n_desc high
byte that is larger than the list of loaded dylibs, checkSymbolTable()
will flag the library ordinal as being out of range. Most of the time
the n_desc field is set to 0 or to small values, but old final linked
binaries exist with N_STAB symbols bearing non-trivial n_desc fields.

The change here is simply to verify a symbol is not an N_STAB symbol
before consulting the values of n_other or n_desc.

rdar://44977336

Reviewers: lhames, pete, ab

Reviewed By: pete

Subscribers: llvm-commits, rupprecht

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58568

llvm-svn: 354722

show more ...


Revision tags: llvmorg-7.1.0, llvmorg-7.1.0-rc1, llvmorg-8.0.0-rc2
# f4c902bd 24-Jan-2019 Michael Trent <mtrent@apple.com>

Limit dyld image suffixes guessed by guessLibraryShortName()

Summary:
guessLibraryShortName() separates a full Mach-O dylib install name path
into a short name and a dyld image suffix. The short nam

Limit dyld image suffixes guessed by guessLibraryShortName()

Summary:
guessLibraryShortName() separates a full Mach-O dylib install name path
into a short name and a dyld image suffix. The short name is the name
of the dylib without its path or extension. The dyld image suffix is a
string used by dyld to load variants of dylibs if available at runtime;
for example, "when binding this process, load 'debug' variants of all
required dylibs." dyld knows exactly what the image suffix is, but
by convention diagnostic tools such as llvm-nm attempt to guess suffix
names by looking at the install name path.

These dyld image suffixes are separated from the short name by a '_'
character. Because the '_' character is commonly used to separate words
in filenames guessLibraryShortName() cannot reliably separate a dylib's
short name from an arbitrary image suffix; imagine if both the short
name and the suffix contains an '_' character! To better deal with this
ambiguity, guessLibraryShortName() will recognize only "_debug" and
"_profile" as valid Suffix values. Calling code needs to be tolerant of
guessLibraryShortName() guessing incorrectly.

The previous implementation of guessLibraryShortName() did not allow
'_' characters to appear in short names. When present, the short name
would be truncated, e.g., "libcompiler_rt" => "libcompiler". This
change allows "libcompiler_rt" and "libcompiler_rt_debug" to both be
recognized as "libcompiler_rt".

rdar://47412244

Reviewers: kledzik, lhames, pete

Reviewed By: pete

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D56978

llvm-svn: 352104

show more ...


Revision tags: llvmorg-8.0.0-rc1
# 2946cd70 19-Jan-2019 Chandler Carruth <chandlerc@gmail.com>

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the ne

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636

show more ...


# 46f0a97e 14-Jan-2019 Lang Hames <lhames@gmail.com>

[Object] Return a symbol_iterator, rather than a basic_symbol_iterator, from
MachOObjectFile::getSymbolByIndex.

ObjectFile derivatives should prefer symbol_iterator/SymbolRef over
basic_symbol_itera

[Object] Return a symbol_iterator, rather than a basic_symbol_iterator, from
MachOObjectFile::getSymbolByIndex.

ObjectFile derivatives should prefer symbol_iterator/SymbolRef over
basic_symbol_iterator/BasicSymbolRef where possible, as the former
retain their link to the ObjectFile (rather than a SymbolicFile) and provide
more functionality.

No test for this: Existing code is working, and we don't have (m)any libObject
unit tests. I'll think about how we can test more systematically going forward.

llvm-svn: 351128

show more ...


Revision tags: llvmorg-7.0.1, llvmorg-7.0.1-rc3, llvmorg-7.0.1-rc2, llvmorg-7.0.1-rc1, llvmorg-7.0.0, llvmorg-7.0.0-rc3
# 2d3f01c5 04-Sep-2018 Francis Visoiu Mistrih <francisvm@yahoo.com>

[MachO] Fix inconsistency between error messages when validating LC_DYSYMTAB

llvm-svn: 341379


# 7690af4d 04-Sep-2018 Francis Visoiu Mistrih <francisvm@yahoo.com>

[MachO] Fix LC_DYSYMTAB validation for external symbols

We were validating the same index (ilocalsym) twice, while iextdefsym
was never validated.

llvm-svn: 341378


Revision tags: llvmorg-7.0.0-rc2, llvmorg-7.0.0-rc1
# b98f5048 11-Jul-2018 Paul Semel <semelpaul@gmail.com>

[llvm-readobj] Add -hex-dump (-x) option

Differential Revision: https://reviews.llvm.org/D48281

llvm-svn: 336782


Revision tags: llvmorg-6.0.1, llvmorg-6.0.1-rc3
# 675a5175 04-Jun-2018 Sam Clegg <sbc@chromium.org>

[MachO] Add out-of-bounds check to MachOObjectFile.cpp

This is a followup to rL333496.

Differential Revision: https://reviews.llvm.org/D47544

llvm-svn: 333929


Revision tags: llvmorg-6.0.1-rc2
# a81fb848 30-May-2018 Sam Clegg <sbc@chromium.org>

MC: Remove redundant substr() call

Differential Revision: https://reviews.llvm.org/D47047

llvm-svn: 333496


# 1834682b 19-Apr-2018 Francis Visoiu Mistrih <francisvm@yahoo.com>

[llvm-objdump] Print "..." instead of random data for virtual sections

When disassembling with -D, skip virtual sections by printing "..." for
each symbol.

This patch also implements `MachOObjectFi

[llvm-objdump] Print "..." instead of random data for virtual sections

When disassembling with -D, skip virtual sections by printing "..." for
each symbol.

This patch also implements `MachOObjectFile::isSectionVirtual`.

Test case comes from:

```
.zerofill __DATA,__common,_data64unsigned,472,3
```

Differential Revision: https://reviews.llvm.org/D45824

llvm-svn: 330342

show more ...


Revision tags: llvmorg-6.0.1-rc1, llvmorg-5.0.2, llvmorg-5.0.2-rc2, llvmorg-5.0.2-rc1
# 299cd890 08-Mar-2018 Kevin Enderby <enderby@apple.com>

For llvm-objdump and Mach-O files, update the printing of some thread states
from core files. I tested this against the couple of core files that were
getting errors about unknown thread flavors and

For llvm-objdump and Mach-O files, update the printing of some thread states
from core files. I tested this against the couple of core files that were
getting errors about unknown thread flavors and it now produce the same output as
the Xcode otool-classic(1) tool. Since the core files are huge I didn’t include
them as test cases.

rdar://38216356

llvm-svn: 327077

show more ...


Revision tags: llvmorg-6.0.0, llvmorg-6.0.0-rc3, llvmorg-6.0.0-rc2, llvmorg-6.0.0-rc1
# ca30902f 03-Jan-2018 Michael Trent <mtrent@apple.com>

Do not look up symbol names when n_strx == 0

Summary:
Historical tools for working with mach-o binaries verify the nlist field
n_strx has a non-zero value before using that value to retrieve symbol

Do not look up symbol names when n_strx == 0

Summary:
Historical tools for working with mach-o binaries verify the nlist field
n_strx has a non-zero value before using that value to retrieve symbol names.
Under some cirumstances, llvm-nm will attempt to display the symbol name at
position 0, even though symbol names at that position are not well defined.
This change addresses this problem by returning an empty string when n_strx
is zero.

rdar://problem/35750548

Reviewers: enderby, davide

Reviewed By: enderby, davide

Subscribers: davide, llvm-commits, JDevlieghere

Differential Revision: https://reviews.llvm.org/D41657

llvm-svn: 321773

show more ...


# a1703b1f 15-Dec-2017 Michael Trent <mtrent@apple.com>

Updated llvm-objdump to display local relocations in Mach-O binaries

Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This

Updated llvm-objdump to display local relocations in Mach-O binaries

Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O
parser to display local relocations for MH_PRELOAD files. When used with
the -macho option relocations will be displayed in a historical format.

All tests are passing for llvm, clang, and lld. llvm-objdump builds without
compiler warnings.

rdar://35778019

Reviewers: enderby

Reviewed By: enderby

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D41199

llvm-svn: 320832

show more ...


# 260fe3ec 14-Dec-2017 Zachary Turner <zturner@google.com>

Fix many -Wsign-compare and -Wtautological-constant-compare warnings.

Most of the -Wsign-compare warnings are due to the fact that
enums are signed by default in the MS ABI, while the
tautological c

Fix many -Wsign-compare and -Wtautological-constant-compare warnings.

Most of the -Wsign-compare warnings are due to the fact that
enums are signed by default in the MS ABI, while the
tautological comparison warnings trigger on x86 builds where
sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max()
is always false.

Differential Revision: https://reviews.llvm.org/D41256

llvm-svn: 320750

show more ...


# 1d3d8ada 13-Dec-2017 Michael Trent <mtrent@apple.com>

reverting out -r320532 because a warning is breaking the lld build

llvm-svn: 320534


# 0f6bfaf1 12-Dec-2017 Michael Trent <mtrent@apple.com>

Updated llvm-objdump to display local relocations in Mach-O binaries

Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This

Updated llvm-objdump to display local relocations in Mach-O binaries

Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O
parser to display local relocations for MH_PRELOAD files. When used with
the -macho option relocations will be displayed in a historical format.

rdar://35778019

Reviewers: enderby

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D41061

llvm-svn: 320532

show more ...


# ad840d22 08-Dec-2017 Michael Trent <mtrent@apple.com>

Reverting r320166 to fix test failures.

llvm-svn: 320174


12345678910>>...20