This allows us to remove checks for the linker symbols for the beginning and the end of the .bss section. Instead, we use the names from the linker script. Another benefit is a better unification of the build system.
ChangeLog: * aclocal.m4: Remove grub_CHECK_BSS_START_SYMBOL and grub_CHECK_END_SYMBOL. * configure.ac: Don't call grub_CHECK_BSS_START_SYMBOL and grub_CHECK_END_SYMBOL. Check for ${target_cpu}-${platform}.lds as the linker script. * conf/i386-pc-cygwin-img-ld.sc: Rename to ... * conf/i386-pc.lds: ... this. * kern/i386/pc/startup.S: Use __bss_start__ and __bss_end__ instead of BSS_START_SYMBOL and END_SYMBOL. --- aclocal.m4 | 77 ----------------------------------------- conf/i386-pc-cygwin-img-ld.sc | 53 ---------------------------- conf/i386-pc.lds | 53 ++++++++++++++++++++++++++++ configure.ac | 10 ++--- kern/i386/pc/startup.S | 8 ++-- 5 files changed, 60 insertions(+), 141 deletions(-) delete mode 100644 conf/i386-pc-cygwin-img-ld.sc create mode 100644 conf/i386-pc.lds diff --git a/aclocal.m4 b/aclocal.m4 index 779df3d..9a073b5 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -224,83 +224,6 @@ fi AC_MSG_RESULT([$grub_cv_i386_asm_absolute_without_asterisk])]) -dnl Check what symbol is defined as a bss start symbol. -dnl Written by Michael Hohmoth and Yoshinori K. Okuji. -AC_DEFUN(grub_CHECK_BSS_START_SYMBOL, -[AC_REQUIRE([AC_PROG_CC]) -AC_MSG_CHECKING([if __bss_start is defined by the compiler]) -AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol, -[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], - [[asm ("incl __bss_start")]])], - [grub_cv_check_uscore_uscore_bss_start_symbol=yes], - [grub_cv_check_uscore_uscore_bss_start_symbol=no])]) - -AC_MSG_RESULT([$grub_cv_check_uscore_uscore_bss_start_symbol]) - -AC_MSG_CHECKING([if edata is defined by the compiler]) -AC_CACHE_VAL(grub_cv_check_edata_symbol, -[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], - [[asm ("incl edata")]])], - [grub_cv_check_edata_symbol=yes], - [grub_cv_check_edata_symbol=no])]) - -AC_MSG_RESULT([$grub_cv_check_edata_symbol]) - -AC_MSG_CHECKING([if _edata is defined by the compiler]) -AC_CACHE_VAL(grub_cv_check_uscore_edata_symbol, -[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], - [[asm ("incl _edata")]])], - [grub_cv_check_uscore_edata_symbol=yes], - [grub_cv_check_uscore_edata_symbol=no])]) - -AC_MSG_RESULT([$grub_cv_check_uscore_edata_symbol]) - -AH_TEMPLATE([BSS_START_SYMBOL], [Define it to one of __bss_start, edata and _edata]) - -if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then - AC_DEFINE([BSS_START_SYMBOL], [__bss_start]) -elif test "x$grub_cv_check_edata_symbol" = xyes; then - AC_DEFINE([BSS_START_SYMBOL], [edata]) -elif test "x$grub_cv_check_uscore_edata_symbol" = xyes; then - AC_DEFINE([BSS_START_SYMBOL], [_edata]) -else - AC_MSG_ERROR([none of __bss_start, edata or _edata is defined]) -fi -]) - -dnl Check what symbol is defined as an end symbol. -dnl Written by Yoshinori K. Okuji. -AC_DEFUN(grub_CHECK_END_SYMBOL, -[AC_REQUIRE([AC_PROG_CC]) -AC_MSG_CHECKING([if end is defined by the compiler]) -AC_CACHE_VAL(grub_cv_check_end_symbol, -[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], - [[asm ("incl end")]])], - [grub_cv_check_end_symbol=yes], - [grub_cv_check_end_symbol=no])]) - -AC_MSG_RESULT([$grub_cv_check_end_symbol]) - -AC_MSG_CHECKING([if _end is defined by the compiler]) -AC_CACHE_VAL(grub_cv_check_uscore_end_symbol, -[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], - [[asm ("incl _end")]])], - [grub_cv_check_uscore_end_symbol=yes], - [grub_cv_check_uscore_end_symbol=no])]) - -AC_MSG_RESULT([$grub_cv_check_uscore_end_symbol]) - -AH_TEMPLATE([END_SYMBOL], [Define it to either end or _end]) - -if test "x$grub_cv_check_end_symbol" = xyes; then - AC_DEFINE([END_SYMBOL], [end]) -elif test "x$grub_cv_check_uscore_end_symbol" = xyes; then - AC_DEFINE([END_SYMBOL], [_end]) -else - AC_MSG_ERROR([neither end nor _end is defined]) -fi -]) - dnl Check if the C compiler has a bug while using nested functions when dnl mregparm is used on the i386. Some gcc versions do not pass the third dnl parameter correctly to the nested function. diff --git a/conf/i386-pc-cygwin-img-ld.sc b/conf/i386-pc-cygwin-img-ld.sc deleted file mode 100644 index a41cac7..0000000 --- a/conf/i386-pc-cygwin-img-ld.sc +++ /dev/null @@ -1,53 +0,0 @@ -/* Linker script to create grub .img files on Cygwin. */ - -SECTIONS -{ - .text : - { - start = . ; - *(.text) - etext = . ; - } - .data : - { - __data_start__ = . ; - *(.data) - __data_end__ = . ; - } - .rdata : - { - __rdata_start__ = . ; - *(.rdata) - __rdata_end__ = . ; - } - .pdata : - { - *(.pdata) - edata = . ; - } - .bss : - { - __bss_start__ = . ; - *(.bss) - __common_start__ = . ; - *(COMMON) - __bss_end__ = . ; - } - .edata : - { - *(.edata) - end = . ; - } - .stab : - { - *(.stab) - } - .stabstr : - { - *(.stabstr) - } -} - -ASSERT("__rdata_end__"=="edata", ".pdata not empty") -ASSERT("__bss_end__" =="end" , ".edata not empty") - diff --git a/conf/i386-pc.lds b/conf/i386-pc.lds new file mode 100644 index 0000000..a41cac7 --- /dev/null +++ b/conf/i386-pc.lds @@ -0,0 +1,53 @@ +/* Linker script to create grub .img files on Cygwin. */ + +SECTIONS +{ + .text : + { + start = . ; + *(.text) + etext = . ; + } + .data : + { + __data_start__ = . ; + *(.data) + __data_end__ = . ; + } + .rdata : + { + __rdata_start__ = . ; + *(.rdata) + __rdata_end__ = . ; + } + .pdata : + { + *(.pdata) + edata = . ; + } + .bss : + { + __bss_start__ = . ; + *(.bss) + __common_start__ = . ; + *(COMMON) + __bss_end__ = . ; + } + .edata : + { + *(.edata) + end = . ; + } + .stab : + { + *(.stab) + } + .stabstr : + { + *(.stabstr) + } +} + +ASSERT("__rdata_end__"=="edata", ".pdata not empty") +ASSERT("__bss_end__" =="end" , ".edata not empty") + diff --git a/configure.ac b/configure.ac index d84e2b6..a048828 100644 --- a/configure.ac +++ b/configure.ac @@ -209,10 +209,10 @@ AC_CHECK_FUNCS(posix_memalign memalign asprintf) # Use linker script if present, otherwise use builtin -N script. AC_MSG_CHECKING([for option to link raw image]) -if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then - TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc" +if test -f "${srcdir}/conf/${target_cpu}-${platform}.lds"; then + TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}.lds" TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}" - TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc" + TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}.lds" else TARGET_IMG_LDSCRIPT= TARGET_IMG_LDFLAGS='-Wl,-N' @@ -383,10 +383,6 @@ if test "x$target_cpu" = xi386; then # Check symbols provided by linker script. CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100" fi - if test "x$platform" = xpc; then - grub_CHECK_BSS_START_SYMBOL - grub_CHECK_END_SYMBOL - fi CFLAGS="$TARGET_CFLAGS" grub_I386_ASM_PREFIX_REQUIREMENT grub_I386_ASM_ADDR32 diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index 8e8b661..471a8d3 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -241,7 +241,7 @@ codestart: addl %ecx, %esi addl $_start, %esi decl %esi - movl $END_SYMBOL, %edi + movl $__bss_end__, %edi addl %ecx, %edi decl %edi std @@ -250,10 +250,10 @@ codestart: #endif /* clean out the bss */ - movl $BSS_START_SYMBOL, %edi + movl $__bss_start__, %edi /* compute the bss length */ - movl $END_SYMBOL, %ecx + movl $__bss_end__, %ecx subl %edi, %ecx /* clean out */ @@ -285,7 +285,7 @@ VARIABLE(grub_start_addr) .long _start VARIABLE(grub_end_addr) - .long END_SYMBOL + .long __bss_end__ VARIABLE(grub_apm_bios_info) .word 0 /* version */ _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel