Move ctors symbol in its own section to force alignment.

Add -g3 flag for release compilation.
This commit is contained in:
jief666 2021-04-05 23:35:34 +03:00
parent 6545450f02
commit 5d20632984
6 changed files with 11 additions and 11 deletions

View File

@ -2416,9 +2416,9 @@ RELEASE_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
#Jief removed lto flag. It is set in CLover.dsc, from the env var 'DISABLE_LTO'
DEBUG_GCC53_X64_CC_FLAGS = DEF(GCC53_X64_CC_FLAGS) -g3 -O0
RELEASE_GCC53_X64_CC_FLAGS = DEF(GCC53_X64_CC_FLAGS) -Os -Werror
RELEASE_GCC53_X64_CC_FLAGS = DEF(GCC53_X64_CC_FLAGS) -g3 -Os -Werror
DEBUG_GCC53_X64_CXX_FLAGS = DEF(GCC53_X64_CC_FLAGS) -g3 -O0
RELEASE_GCC53_X64_CXX_FLAGS = DEF(GCC53_X64_CC_FLAGS) -Os -Werror
RELEASE_GCC53_X64_CXX_FLAGS = DEF(GCC53_X64_CC_FLAGS) -g3 -Os -Werror
#
#

View File

@ -45,11 +45,14 @@ SECTIONS {
.data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
*(.data .data.* .gnu.linkonce.d.*)
*(.bss .bss.*)
__beginning_of_section_ctors = .; /* create symbol for start of section */
KEEP(*(.ctors .init_array)) /* .ctors is used on macOS, .init_array on Linux */
__end_of_section_ctors = .; /* create symbol for end of section */
}
.ctors ALIGN(CONSTANT(COMMONPAGESIZE)) : {
__beginning_of_section_ctors = .; /* create symbol for start of section */
KEEP (*(.ctors .init_array)) /* .ctors is used on macOS, .init_array on Linux */
__end_of_section_ctors = .; /* create symbol for end of section */
}
.eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
KEEP (*(.eh_frame))
}

View File

@ -612,7 +612,7 @@ mCoffOffset=mCoffOffsetNew;
// if the section address is aligned we must align PE/COFF
UINT32 mCoffOffsetNew = (UINT32) ((shdr->sh_addr + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
printf("Section %d %s mCoffOffset=%d(0x%x) mCoffOffsetNew=%d(0x%x) diff=%d(0x%x), size=%llu\n", i, sectName, mCoffOffset, mCoffOffset, mCoffOffsetNew, mCoffOffsetNew, mCoffOffsetNew-mCoffOffset, mCoffOffsetNew-mCoffOffset, shdr->sh_size);
printf("Section %d %s mCoffOffset=%d(0x%x) mCoffOffsetNew=%d(0x%x) diff=%d(0x%x), size=%llu\n", i, sectName, mCoffOffset, mCoffOffset, mCoffOffsetNew, mCoffOffsetNew, mCoffOffsetNew-mCoffOffset, mCoffOffsetNew-mCoffOffset, shdr->sh_size);
mCoffOffset=mCoffOffsetNew;
} else {
Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");

View File

@ -125,7 +125,7 @@ then
exit 1
fi
adr="$(grep "$image_base_str" ./serial0_qemu_out.log | awk '{printf "0x%x",$6}')"
adr="$(grep "$image_base_str" ./serial0_qemu_out.log | awk '{printf "0x%x",$NF}')"
echo adr="$adr"
GDB=gdb

View File

@ -116,7 +116,7 @@ then
exit 1
fi
adr="$(grep "$image_base_str" ./serial0_qemu_out.log | awk '{printf "0x%x",$6}')"
adr="$(grep "$image_base_str" ./serial0_qemu_out.log | awk '{printf "0x%x",$NF}')"
echo adr="$adr"

View File

@ -2826,15 +2826,12 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// }
if ( !EFI_ERROR(Status) ) {
DBG("CloverX64 : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger
} else {
DBG("CloverX64 : Image base = 0\n");
}
#ifdef JIEF_DEBUG
gBS->Stall(2500000); // to give time to gdb to connect
// PauseForKey(L"press\n");
#endif
}
gBS->Stall(2500000); // to give time to gdb to connect
#ifdef CLOVER_BUILD
construct_globals_objects(gImageHandle); // do this after self.getSelfLoadedImage() is initialized