forked from OSchip/llvm-project
Rename align2 -> align.
I believe "2" stands for log2. Just "align" would be appropriate now. llvm-svn: 233248
This commit is contained in:
parent
39eb6db9a5
commit
da74d57edb
|
@ -228,10 +228,10 @@ public:
|
|||
const StringRefVector &rpaths() const { return _rpaths; }
|
||||
|
||||
/// Add section alignment constraint on final layout.
|
||||
void addSectionAlignment(StringRef seg, StringRef sect, uint16_t align2);
|
||||
void addSectionAlignment(StringRef seg, StringRef sect, uint16_t align);
|
||||
|
||||
/// Returns true if specified section had alignment constraints.
|
||||
bool sectionAligned(StringRef seg, StringRef sect, uint16_t &align2) const;
|
||||
bool sectionAligned(StringRef seg, StringRef sect, uint16_t &align) const;
|
||||
|
||||
StringRef dyldPath() const { return "/usr/lib/dyld"; }
|
||||
|
||||
|
@ -312,7 +312,7 @@ private:
|
|||
struct SectionAlign {
|
||||
StringRef segmentName;
|
||||
StringRef sectionName;
|
||||
uint16_t align2;
|
||||
uint16_t align;
|
||||
};
|
||||
|
||||
struct OrderFileNode {
|
||||
|
|
|
@ -479,15 +479,15 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
|
|||
<< alignStr << "' not a valid number\n";
|
||||
return false;
|
||||
}
|
||||
uint16_t align2 = 1 << llvm::countTrailingZeros(alignValue);
|
||||
uint16_t align = 1 << llvm::countTrailingZeros(alignValue);
|
||||
if (!llvm::isPowerOf2_64(alignValue)) {
|
||||
diagnostics << "warning: alignment for '-sectalign "
|
||||
<< segName << " " << sectName
|
||||
<< llvm::format(" 0x%llX", alignValue)
|
||||
<< "' is not a power of two, using "
|
||||
<< llvm::format("0x%08X", align2) << "\n";
|
||||
<< llvm::format("0x%08X", align) << "\n";
|
||||
}
|
||||
ctx.addSectionAlignment(segName, sectName, align2);
|
||||
ctx.addSectionAlignment(segName, sectName, align);
|
||||
}
|
||||
|
||||
// Handle -mllvm
|
||||
|
|
|
@ -731,16 +731,16 @@ ArchHandler &MachOLinkingContext::archHandler() const {
|
|||
|
||||
|
||||
void MachOLinkingContext::addSectionAlignment(StringRef seg, StringRef sect,
|
||||
uint16_t align2) {
|
||||
SectionAlign entry = { seg, sect, align2 };
|
||||
uint16_t align) {
|
||||
SectionAlign entry = { seg, sect, align };
|
||||
_sectAligns.push_back(entry);
|
||||
}
|
||||
|
||||
bool MachOLinkingContext::sectionAligned(StringRef seg, StringRef sect,
|
||||
uint16_t &align2) const {
|
||||
uint16_t &align) const {
|
||||
for (const SectionAlign &entry : _sectAligns) {
|
||||
if (seg.equals(entry.segmentName) && sect.equals(entry.sectionName)) {
|
||||
align2 = entry.align2;
|
||||
align = entry.align;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,17 +327,17 @@ void Util::appendAtom(SectionInfo *sect, const DefinedAtom *atom) {
|
|||
// Figure out offset for atom in this section given alignment constraints.
|
||||
uint64_t offset = sect->size;
|
||||
DefinedAtom::Alignment atomAlign = atom->alignment();
|
||||
uint64_t align2 = atomAlign.value;
|
||||
uint64_t align = atomAlign.value;
|
||||
uint64_t requiredModulus = atomAlign.modulus;
|
||||
uint64_t currentModulus = (offset % align2);
|
||||
uint64_t currentModulus = (offset % align);
|
||||
if ( currentModulus != requiredModulus ) {
|
||||
if ( requiredModulus > currentModulus )
|
||||
offset += requiredModulus-currentModulus;
|
||||
else
|
||||
offset += align2+requiredModulus-currentModulus;
|
||||
offset += align+requiredModulus-currentModulus;
|
||||
}
|
||||
// Record max alignment of any atom in this section.
|
||||
if (align2 > sect->alignment)
|
||||
if (align > sect->alignment)
|
||||
sect->alignment = atomAlign.value;
|
||||
// Assign atom to this section with this offset.
|
||||
AtomInfo ai = {atom, offset};
|
||||
|
|
Loading…
Reference in New Issue