Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1J39OH-0002cl-1Z for mharc-grub-devel@gnu.org; Fri, 14 Dec 2007 07:11:41 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J39OF-0002aO-Kq for grub-devel@gnu.org; Fri, 14 Dec 2007 07:11:39 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J39OE-0002Xa-4q for grub-devel@gnu.org; Fri, 14 Dec 2007 07:11:38 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J39OD-0002XN-Vj for grub-devel@gnu.org; Fri, 14 Dec 2007 07:11:38 -0500 Received: from wa-out-1112.google.com ([209.85.146.176]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J39OD-0007F6-Ji for grub-devel@gnu.org; Fri, 14 Dec 2007 07:11:37 -0500 Received: by wa-out-1112.google.com with SMTP id k34so1738875wah.10 for ; Fri, 14 Dec 2007 04:11:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=8NDPUWdO/MEDlqyg4lcSK7Z0LbOngDFkeGwoqaT0VAM=; b=MV2VL52XFJB8IyCu4dXfig3x2kCUvVmlfJf5AlOJJn6creBXjA8RR2HP8zfamxzjUBazxdNFZoxNlSQEz3Uz7SzxSG3LunVSaOTEzkd9H4PlPPyNY3F8TmRLYK6PhcD24+gWs929V8alY7jDd51+8Bl4+fxZlKGeuanb2XupugI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=MNkwIja0Y6+MQeihQ+ra6pePZlcOq/ZL2h9bVnW82rbhpUSXAZwzUeayA0NLosuD49IpizIjF9dDIMrPq5GW23wDHQ/eI8ETPQf5l+/yRnELudzYtsio8kFFkRFaOcbdhA1pjJnKLpoeEoLdfim3dsVvTUjOLaWXglLiefwtTz0= Received: by 10.143.16.9 with SMTP id t9mr1367816wfi.164.1197634296688; Fri, 14 Dec 2007 04:11:36 -0800 (PST) Received: by 10.35.123.19 with HTTP; Fri, 14 Dec 2007 04:11:36 -0800 (PST) Message-ID: Date: Fri, 14 Dec 2007 20:11:36 +0800 From: Bean To: "The development of GRUB 2" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: [PATCH] Use linker script to remove unnecessary sections X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2007 12:11:39 -0000 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 * 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