[PECOFF] Use a shorter name for the parameter.

llvm-svn: 200107
This commit is contained in:
Rui Ueyama 2014-01-26 00:37:30 +00:00
parent 76c1b4d0fb
commit c6ddf5654c
1 changed files with 23 additions and 23 deletions

View File

@ -125,7 +125,7 @@ private:
/// A PEHeaderChunk represents PE header including COFF header. /// A PEHeaderChunk represents PE header including COFF header.
class PEHeaderChunk : public HeaderChunk { class PEHeaderChunk : public HeaderChunk {
public: public:
explicit PEHeaderChunk(const PECOFFLinkingContext &context); explicit PEHeaderChunk(const PECOFFLinkingContext &ctx);
virtual void write(uint8_t *buffer); virtual void write(uint8_t *buffer);
@ -310,14 +310,14 @@ private:
std::vector<uint8_t> _contents; std::vector<uint8_t> _contents;
}; };
PEHeaderChunk::PEHeaderChunk(const PECOFFLinkingContext &context) PEHeaderChunk::PEHeaderChunk(const PECOFFLinkingContext &ctx)
: HeaderChunk() { : HeaderChunk() {
// Set the size of the chunk and initialize the header with null bytes. // Set the size of the chunk and initialize the header with null bytes.
_size = sizeof(llvm::COFF::PEMagic) + sizeof(_coffHeader) + sizeof(_peHeader); _size = sizeof(llvm::COFF::PEMagic) + sizeof(_coffHeader) + sizeof(_peHeader);
std::memset(&_coffHeader, 0, sizeof(_coffHeader)); std::memset(&_coffHeader, 0, sizeof(_coffHeader));
std::memset(&_peHeader, 0, sizeof(_peHeader)); std::memset(&_peHeader, 0, sizeof(_peHeader));
_coffHeader.Machine = context.getMachineType(); _coffHeader.Machine = ctx.getMachineType();
_coffHeader.TimeDateStamp = time(nullptr); _coffHeader.TimeDateStamp = time(nullptr);
// The size of PE header including optional data directory is always 224. // The size of PE header including optional data directory is always 224.
@ -326,19 +326,19 @@ PEHeaderChunk::PEHeaderChunk(const PECOFFLinkingContext &context)
// Attributes of the executable. // Attributes of the executable.
uint16_t characteristics = llvm::COFF::IMAGE_FILE_32BIT_MACHINE | uint16_t characteristics = llvm::COFF::IMAGE_FILE_32BIT_MACHINE |
llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE; llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
if (context.getLargeAddressAware()) if (ctx.getLargeAddressAware())
characteristics |= llvm::COFF::IMAGE_FILE_LARGE_ADDRESS_AWARE; characteristics |= llvm::COFF::IMAGE_FILE_LARGE_ADDRESS_AWARE;
if (context.getSwapRunFromCD()) if (ctx.getSwapRunFromCD())
characteristics |= llvm::COFF::IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP; characteristics |= llvm::COFF::IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP;
if (context.getSwapRunFromNet()) if (ctx.getSwapRunFromNet())
characteristics |= llvm::COFF::IMAGE_FILE_NET_RUN_FROM_SWAP; characteristics |= llvm::COFF::IMAGE_FILE_NET_RUN_FROM_SWAP;
if (!context.getBaseRelocationEnabled()) if (!ctx.getBaseRelocationEnabled())
characteristics |= llvm::COFF::IMAGE_FILE_RELOCS_STRIPPED; characteristics |= llvm::COFF::IMAGE_FILE_RELOCS_STRIPPED;
_coffHeader.Characteristics = characteristics; _coffHeader.Characteristics = characteristics;
_peHeader.Magic = context.is64Bit() ? llvm::COFF::PE32Header::PE32_PLUS _peHeader.Magic = ctx.is64Bit() ? llvm::COFF::PE32Header::PE32_PLUS
: llvm::COFF::PE32Header::PE32; : llvm::COFF::PE32Header::PE32;
// The address of entry point relative to ImageBase. Windows executable // The address of entry point relative to ImageBase. Windows executable
// usually starts at address 0x401000. // usually starts at address 0x401000.
@ -346,11 +346,11 @@ PEHeaderChunk::PEHeaderChunk(const PECOFFLinkingContext &context)
// The address of the executable when loaded into memory. The default for // The address of the executable when loaded into memory. The default for
// DLLs is 0x10000000. The default for executables is 0x400000. // DLLs is 0x10000000. The default for executables is 0x400000.
_peHeader.ImageBase = context.getBaseAddress(); _peHeader.ImageBase = ctx.getBaseAddress();
// Sections should be page-aligned when loaded into memory, which is 4KB on // Sections should be page-aligned when loaded into memory, which is 4KB on
// x86. // x86.
_peHeader.SectionAlignment = context.getSectionDefaultAlignment(); _peHeader.SectionAlignment = ctx.getSectionDefaultAlignment();
// Sections in an executable file on disk should be sector-aligned (512 byte). // Sections in an executable file on disk should be sector-aligned (512 byte).
_peHeader.FileAlignment = SECTOR_SIZE; _peHeader.FileAlignment = SECTOR_SIZE;
@ -358,43 +358,43 @@ PEHeaderChunk::PEHeaderChunk(const PECOFFLinkingContext &context)
// The version number of the resultant executable/DLL. The number is purely // The version number of the resultant executable/DLL. The number is purely
// informative, and neither the linker nor the loader won't use it. User can // informative, and neither the linker nor the loader won't use it. User can
// set the value using /version command line option. Default is 0.0. // set the value using /version command line option. Default is 0.0.
PECOFFLinkingContext::Version imageVersion = context.getImageVersion(); PECOFFLinkingContext::Version imageVersion = ctx.getImageVersion();
_peHeader.MajorImageVersion = imageVersion.majorVersion; _peHeader.MajorImageVersion = imageVersion.majorVersion;
_peHeader.MinorImageVersion = imageVersion.minorVersion; _peHeader.MinorImageVersion = imageVersion.minorVersion;
// The required Windows version number. This is the internal version and // The required Windows version number. This is the internal version and
// shouldn't be confused with product name. Windows 7 is version 6.1 and // shouldn't be confused with product name. Windows 7 is version 6.1 and
// Windows 8 is 6.2, for example. // Windows 8 is 6.2, for example.
PECOFFLinkingContext::Version minOSVersion = context.getMinOSVersion(); PECOFFLinkingContext::Version minOSVersion = ctx.getMinOSVersion();
_peHeader.MajorOperatingSystemVersion = minOSVersion.majorVersion; _peHeader.MajorOperatingSystemVersion = minOSVersion.majorVersion;
_peHeader.MinorOperatingSystemVersion = minOSVersion.minorVersion; _peHeader.MinorOperatingSystemVersion = minOSVersion.minorVersion;
_peHeader.MajorSubsystemVersion = minOSVersion.majorVersion; _peHeader.MajorSubsystemVersion = minOSVersion.majorVersion;
_peHeader.MinorSubsystemVersion = minOSVersion.minorVersion; _peHeader.MinorSubsystemVersion = minOSVersion.minorVersion;
_peHeader.Subsystem = context.getSubsystem(); _peHeader.Subsystem = ctx.getSubsystem();
// Despite its name, DLL characteristics field has meaning both for // Despite its name, DLL characteristics field has meaning both for
// executables and DLLs. We are not very sure if the following bits must // executables and DLLs. We are not very sure if the following bits must
// be set, but regular binaries seem to have these bits, so we follow // be set, but regular binaries seem to have these bits, so we follow
// them. // them.
uint16_t dllCharacteristics = llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_SEH; uint16_t dllCharacteristics = llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_SEH;
if (context.isTerminalServerAware()) if (ctx.isTerminalServerAware())
dllCharacteristics |= dllCharacteristics |=
llvm::COFF::IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE; llvm::COFF::IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE;
if (context.isNxCompat()) if (ctx.isNxCompat())
dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NX_COMPAT; dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NX_COMPAT;
if (context.getDynamicBaseEnabled()) if (ctx.getDynamicBaseEnabled())
dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE; dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE;
if (!context.getAllowBind()) if (!ctx.getAllowBind())
dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_BIND; dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_BIND;
if (!context.getAllowIsolation()) if (!ctx.getAllowIsolation())
dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION; dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION;
_peHeader.DLLCharacteristics = dllCharacteristics; _peHeader.DLLCharacteristics = dllCharacteristics;
_peHeader.SizeOfStackReserve = context.getStackReserve(); _peHeader.SizeOfStackReserve = ctx.getStackReserve();
_peHeader.SizeOfStackCommit = context.getStackCommit(); _peHeader.SizeOfStackCommit = ctx.getStackCommit();
_peHeader.SizeOfHeapReserve = context.getHeapReserve(); _peHeader.SizeOfHeapReserve = ctx.getHeapReserve();
_peHeader.SizeOfHeapCommit = context.getHeapCommit(); _peHeader.SizeOfHeapCommit = ctx.getHeapCommit();
// The number of data directory entries. We always have 16 entries. // The number of data directory entries. We always have 16 entries.
_peHeader.NumberOfRvaAndSize = 16; _peHeader.NumberOfRvaAndSize = 16;