[PECOFF] Rename getSectionAlignment -> getSectionDefaultAlignment.

These fields are for /align option. Section alignment can be set per-section
basis with /section option too. In order to avoid name conflicts, rename the
existing identifiers to become more specific. No functionality change.

llvm-svn: 194160
This commit is contained in:
Rui Ueyama 2013-11-06 19:30:14 +00:00
parent 5c19eac1c8
commit 41b99dce59
5 changed files with 14 additions and 10 deletions

View File

@ -34,7 +34,7 @@ public:
PECOFFLinkingContext()
: _baseAddress(0x400000), _stackReserve(1024 * 1024), _stackCommit(4096),
_heapReserve(1024 * 1024), _heapCommit(4096), _noDefaultLibAll(false),
_sectionAlignment(4096),
_sectionDefaultAlignment(4096),
_subsystem(llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN),
_machineType(llvm::COFF::IMAGE_FILE_MACHINE_I386), _imageVersion(0, 0),
_minOSVersion(6, 0), _nxCompat(true), _largeAddressAware(false),
@ -116,8 +116,12 @@ public:
uint64_t getHeapReserve() const { return _heapReserve; }
uint64_t getHeapCommit() const { return _heapCommit; }
void setSectionAlignment(uint32_t val) { _sectionAlignment = val; }
uint32_t getSectionAlignment() const { return _sectionAlignment; }
void setSectionDefaultAlignment(uint32_t val) {
_sectionDefaultAlignment = val;
}
uint32_t getSectionDefaultAlignment() const {
return _sectionDefaultAlignment;
}
void setSubsystem(WindowsSubsystem ss) { _subsystem = ss; }
WindowsSubsystem getSubsystem() const { return _subsystem; }
@ -256,7 +260,7 @@ private:
uint64_t _heapReserve;
uint64_t _heapCommit;
bool _noDefaultLibAll;
uint32_t _sectionAlignment;
uint32_t _sectionDefaultAlignment;
WindowsSubsystem _subsystem;
MachineTypes _machineType;
Version _imageVersion;

View File

@ -651,7 +651,7 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx,
diagnostics << "error: invalid value for /align: " << arg << "\n";
return false;
}
ctx.setSectionAlignment(align);
ctx.setSectionDefaultAlignment(align);
break;
}

View File

@ -53,10 +53,10 @@ bool PECOFFLinkingContext::validateImpl(raw_ostream &diagnostics) {
return false;
}
std::bitset<64> alignment(_sectionAlignment);
std::bitset<64> alignment(_sectionDefaultAlignment);
if (alignment.count() != 1) {
diagnostics << "Section alignment must be a power of 2, but got "
<< _sectionAlignment << "\n";
<< _sectionDefaultAlignment << "\n";
return false;
}

View File

@ -174,7 +174,7 @@ public:
// Sections should be page-aligned when loaded into memory, which is 4KB on
// x86.
_peHeader.SectionAlignment = context.getSectionAlignment();
_peHeader.SectionAlignment = context.getSectionDefaultAlignment();
// Sections in an executable file on disk should be sector-aligned (512 byte).
_peHeader.FileAlignment = SECTOR_SIZE;

View File

@ -50,7 +50,7 @@ TEST_F(WinLinkParserTest, Basic) {
EXPECT_EQ(0x400000U, _context.getBaseAddress());
EXPECT_EQ(1024 * 1024U, _context.getStackReserve());
EXPECT_EQ(4096U, _context.getStackCommit());
EXPECT_EQ(4096U, _context.getSectionAlignment());
EXPECT_EQ(4096U, _context.getSectionDefaultAlignment());
EXPECT_FALSE(_context.allowRemainingUndefines());
EXPECT_TRUE(_context.isNxCompat());
EXPECT_FALSE(_context.getLargeAddressAware());
@ -218,7 +218,7 @@ TEST_F(WinLinkParserTest, InvalidHeapSize) {
TEST_F(WinLinkParserTest, SectionAlignment) {
EXPECT_TRUE(parse("link.exe", "/align:8192", "a.obj", nullptr));
EXPECT_EQ(8192U, _context.getSectionAlignment());
EXPECT_EQ(8192U, _context.getSectionDefaultAlignment());
}
TEST_F(WinLinkParserTest, Section) {