[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Use linker script to remove unnecessary sections
From: |
Bean |
Subject: |
[PATCH] Use linker script to remove unnecessary sections |
Date: |
Fri, 14 Dec 2007 20:11:36 +0800 |
Hi,
This patch use customized linker script to build *.img and *.mod
files, it should remove unnecessary sections created by the compiler.
2007-12-14 Bean <address@hidden>
* conf/i386-pc.rmk (COMMON_LDFLAGS): Use ldscript to link.
* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): Test ldscript.
* configure.ac : Remove the '--build-id=none' flag.
* ldscript : New file.
Index: conf/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.94
diff -u -p -r1.94 i386-pc.rmk
--- conf/i386-pc.rmk 18 Nov 2007 06:41:45 -0000 1.94
+++ conf/i386-pc.rmk 14 Dec 2007 11:51:13 -0000
@@ -2,10 +2,10 @@
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
-COMMON_LDFLAGS = -m32 -nostdlib
+COMMON_LDFLAGS = -m32 -nostdlib -T "${srcdir}/ldscript"
# Images.
pkgdata_IMAGES = boot.img diskboot.img kernel.img pxeboot.img
Index: aclocal.m4
===================================================================
RCS file: /sources/grub/grub2/aclocal.m4,v
retrieving revision 1.7
diff -u -p -r1.7 aclocal.m4
--- aclocal.m4 25 Nov 2007 02:01:30 -0000 1.7
+++ aclocal.m4 14 Dec 2007 11:51:14 -0000
@@ -57,7 +57,7 @@ else
fi
grub_cv_prog_objcopy_absolute=yes
for link_addr in 2000 8000 7C00; do
- if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N
-Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
+ if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-T
"-Wl,${srcdir}/ldscript" -Wl,-Ttext -Wl,$link_addr conftest.o -o
conftest.exec]); then :
else
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
fi
Index: configure.ac
===================================================================
RCS file: /sources/grub/grub2/configure.ac,v
retrieving revision 1.40
diff -u -p -r1.40 configure.ac
--- configure.ac 25 Nov 2007 02:01:30 -0000 1.40
+++ configure.ac 14 Dec 2007 11:51:14 -0000
@@ -229,16 +229,6 @@ if test "x$target_m32" = x1; then
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
fi
-AC_MSG_CHECKING([whether the linker accepts `--build-id=none'])
-save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS -Wl,--build-id=none"
-AC_TRY_LINK(, , build_id_flag=yes, build_id_flag=no)
-AC_MSG_RESULT([$build_id_flag])
-LDFLAGS="$save_LDFLAGS"
-if test "x$build_id_flag" = xyes; then
- TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,--build-id=none"
-fi
-
#
# Compiler features.
#
Index: ldscript
===================================================================
RCS file: /sources/grub/grub2/ldscript,v
diff -Nu ldscript
--- /dev/null 2007-12-15 02:52:31.284046226 +0800
+++ ldscript 2007-12-14 19:37:39.546875000 +0800
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text : { *(.text) } =0x90909090
+ .rodata : { *(.rodata .rodata.*) }
+ .data : { *(.data) }
+ PROVIDE(__bss_start = .);
+ .bss : { *(.bss) *(COMMON) }
+ PROVIDE(end = .);
+ .modname : { *(.modname) }
+ .moddep : { *(.moddep) }
+ /DISCARD/ : { *(*) }
+}
--
Bean
- [PATCH] Use linker script to remove unnecessary sections,
Bean <=