From 41b99dce592ab3150a11ed84e0328bf3b3b78ae7 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 6 Nov 2013 19:30:14 +0000 Subject: [PATCH] [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 --- lld/include/lld/ReaderWriter/PECOFFLinkingContext.h | 12 ++++++++---- lld/lib/Driver/WinLinkDriver.cpp | 2 +- lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp | 4 ++-- lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp | 2 +- lld/unittests/DriverTests/WinLinkDriverTest.cpp | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h index cf8328d8016b..f43766f01fbf 100644 --- a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h +++ b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h @@ -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; diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 0175fb4a146c..4bdd7d7be2e1 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -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; } diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index 0a51b776b5bf..f8a6cd694af7 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -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; } diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index 66260d36c902..1edf6ccee814 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -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; diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp index 36b8e83cfc65..394dadeaa427 100644 --- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp +++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp @@ -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) {