mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-22 13:14:26 +02:00
BaseTools: Update alignment for entry seg for Clang
It does 3 things: 1. Use separate linker file for clang vs GCC for RISCV64. 2. Use common page size instead of max page to ensure -z option align values are properly applied. 3. Enforce alignment for .entry segment as per -z option. When we want to have -z option aligned images, clang while alignes .text and .data segments correctly, .entry segment is by default not aligned unless explicitly specified. This patch makes it explicit to clang that entry seg should also be aligned to requirements. Somehow GCC does not require such explicit entry. Hence detachiong both ld files. Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
This commit is contained in:
parent
1bb10a479f
commit
aca75d3c08
@ -2019,7 +2019,7 @@ DEFINE CLANGDWARF_X64_PREFIX = ENV(CLANG_BIN)
|
||||
|
||||
# LLVM/CLANG doesn't support -n link option. So, it can't share the same IA32_X64_DLINK_COMMON flag.
|
||||
# LLVM/CLANG doesn't support common page size. So, it can't share the same GccBase.lds script.
|
||||
DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections -z max-page-size=0x40
|
||||
DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections -z common-page-size=0x40
|
||||
DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
|
||||
DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
||||
DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive -Wl,-z,notext
|
||||
@ -2200,6 +2200,7 @@ RELEASE_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS) -fl
|
||||
DEFINE CLANGDWARF_RISCV64_TARGET = -target riscv64-linux-gnu
|
||||
DEFINE CLANGDWARF_RISCV64_CC_COMMON = DEF(GCC5_RISCV_ALL_CC_FLAGS) DEF(GCC5_RISCV_ALL_CC_FLAGS_WARNING_DISABLE) DEF(GCC5_RISCV_OPENSBI_TYPES) -march=DEF(GCC5_RISCV64_ARCH) -fno-builtin -fno-builtin-memcpy -fno-stack-protector -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -Wno-unused-but-set-variable -fpack-struct=8 -mcmodel=medany -mabi=lp64 -mno-relax
|
||||
DEFINE CLANGDWARF_RISCV64_CC_FLAGS = DEF(CLANGDWARF_RISCV64_CC_COMMON) DEF(CLANGDWARF_RISCV64_TARGET) DEF(CLANGDWARF_WARNING_OVERRIDES)
|
||||
DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
|
||||
|
||||
# This is similar to GCC flags but without -n
|
||||
DEFINE CLANGDWARF_RISCV64_ALL_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections -z common-page-size=0x40
|
||||
@ -2231,7 +2232,7 @@ DEFINE CLANGDWARF_RISCV64_DLINK_FLAGS = DEF(CLANGDWARF_RISCV64_TARGET) DEF
|
||||
*_CLANGDWARF_RISCV64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) DEF(CLANGDWARF_RISCV64_TARGET) $(PLATFORM_FLAGS) -Qunused-arguments -mabi=lp64 -mno-relax
|
||||
*_CLANGDWARF_RISCV64_DLINK_FLAGS = DEF(CLANGDWARF_RISCV64_TARGET) DEF(GCC5_RISCV64_DLINK_FLAGS)
|
||||
*_CLANGDWARF_RISCV64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
||||
*_CLANGDWARF_RISCV64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x240
|
||||
*_CLANGDWARF_RISCV64_DLINK2_FLAGS = DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x240
|
||||
*_CLANGDWARF_RISCV64_PLATFORM_FLAGS =
|
||||
*_CLANGDWARF_RISCV64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_RISCV64_TARGET) $(PLATFORM_FLAGS)
|
||||
*_CLANGDWARF_RISCV64_RC_FLAGS = DEF(GCC_RISCV64_RC_FLAGS)
|
||||
|
@ -20,7 +20,11 @@ SECTIONS {
|
||||
*/
|
||||
. = PECOFF_HEADER_SIZE;
|
||||
|
||||
.text : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||
.entry ALIGN(CONSTANT(COMMONPAGESIZE)) : {
|
||||
KEEP(*(.entry))
|
||||
}
|
||||
|
||||
.text : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
||||
*(.text .text.* .stub .gnu.linkonce.t.*)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
*(.got .got.*)
|
||||
@ -42,12 +46,12 @@ SECTIONS {
|
||||
* between these sections is the same in the ELF and the PE/COFF versions of
|
||||
* this binary.
|
||||
*/
|
||||
.data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||
.data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
*(.bss .bss.*)
|
||||
}
|
||||
|
||||
.eh_frame ALIGN(CONSTANT(MAXPAGESIZE)) : {
|
||||
.eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
|
||||
KEEP (*(.eh_frame))
|
||||
}
|
||||
|
||||
@ -55,7 +59,7 @@ SECTIONS {
|
||||
*(.rela .rela.*)
|
||||
}
|
||||
|
||||
.hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||
.hii : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
||||
KEEP (*(.hii))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user