Skip to content

Commit

Permalink
[Object] Add public MaxSectionAlignment to MachOUniversal
Browse files Browse the repository at this point in the history
Change MAXSECTALIGN to a public MaxSectionAlignment in MachOUniversal.
Will be used in a follow-up.

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

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

llvm-svn: 366969
  • Loading branch information
smeenai committed Jul 25, 2019
1 parent 7418b10 commit a67f6f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions llvm/include/llvm/Object/MachOUniversal.h
Expand Up @@ -31,6 +31,8 @@ class MachOUniversalBinary : public Binary {
uint32_t Magic;
uint32_t NumberOfObjects;
public:
static constexpr uint32_t MaxSectionAlignment = 15; /* 2**15 or 0x8000 */

class ObjectForArch {
const MachOUniversalBinary *Parent;
/// Index of object in the universal binary.
Expand Down
13 changes: 7 additions & 6 deletions llvm/lib/Object/MachOUniversal.cpp
Expand Up @@ -155,12 +155,13 @@ MachOUniversalBinary::MachOUniversalBinary(MemoryBufferRef Source, Error &Err)
") extends past the end of the file");
return;
}
#define MAXSECTALIGN 15 /* 2**15 or 0x8000 */
if (A.getAlign() > MAXSECTALIGN) {
Err = malformedError("align (2^" + Twine(A.getAlign()) + ") too large "
"for cputype (" + Twine(A.getCPUType()) + ") cpusubtype (" +
Twine(A.getCPUSubType() & ~MachO::CPU_SUBTYPE_MASK) +
") (maximum 2^" + Twine(MAXSECTALIGN) + ")");

if (A.getAlign() > MaxSectionAlignment) {
Err = malformedError("align (2^" + Twine(A.getAlign()) +
") too large for cputype (" + Twine(A.getCPUType()) +
") cpusubtype (" +
Twine(A.getCPUSubType() & ~MachO::CPU_SUBTYPE_MASK) +
") (maximum 2^" + Twine(MaxSectionAlignment) + ")");
return;
}
if(A.getOffset() % (1 << A.getAlign()) != 0){
Expand Down

0 comments on commit a67f6f1

Please sign in to comment.