From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1915 invoked by alias); 9 Dec 2007 02:51:26 -0000 Received: (qmail 1902 invoked by uid 22791); 9 Dec 2007 02:51:25 -0000 X-Spam-Check-By: sourceware.org Received: from wa-out-1112.google.com (HELO wa-out-1112.google.com) (209.85.146.177) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 09 Dec 2007 02:51:18 +0000 Received: by wa-out-1112.google.com with SMTP id l35so2531426waf for ; Sat, 08 Dec 2007 18:51:16 -0800 (PST) Received: by 10.114.123.1 with SMTP id v1mr5449349wac.1197168676040; Sat, 08 Dec 2007 18:51:16 -0800 (PST) Received: from ghost ( [221.218.185.158]) by mx.google.com with ESMTPS id k24sm3188152waf.2007.12.08.18.51.10 (version=SSLv3 cipher=OTHER); Sat, 08 Dec 2007 18:51:14 -0800 (PST) Date: Sun, 09 Dec 2007 02:51:00 -0000 From: "PRC" To: binutils Subject: How to inform the linker not to produce any data for a .bss section? Message-ID: <200712091050318718404@gmail.com> X-mailer: Foxmail 6, 9, 201, 16 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00042.txt.bz2 Here is my link script: -------------------------------------------------------------------- OUTPUT_ARCH(mips) SECTIONS { .text 0x811ed000 : { _dstart = ABSOLUTE(.) ; /* Start of code and data */ *(.libc) *(.text*) *(.rodata*) } .data : { *(.data) } .sbss : { *(.sbss) *(.scommon) } .bss : { *(.bss) *(COMMON) } _dend = ABSOLUTE(.) ; /* end of code and data */ } -------------------------------------------------------------------- and mips-elf-objdump -h a.out shows: a.out: file format elf32-littlemips Sections: Idx Name Size VMA LMA File off Algn 0 .text 00001ab4 811ed000 811ed000 00001000 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .data 0000004c 811eeab4 811eeab4 00002ab4 2**2 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000620 811eeb00 811eeb00 00002b00 2**3 ALLOC 3 .reginfo 00000018 00000000 00000000 00002b00 2**2 CONTENTS, READONLY, LINK_ONCE_SAME_SIZE 4 .pdr 000003c0 00000000 00000000 00002b18 2**2 CONTENTS, READONLY 5 .mdebug.abi32 00000000 00000000 00000000 00002ed8 2**0 CONTENTS, READONLY The linker create a real '.bss' section in the output ELF file and store some data inside the section, which greatly increase the size of the ELF file. How can I do to inform the linker don't produce any data for the .bss section? My linker is: mips-elf-ld -v GNU ld version 2.15 BTW, I'd like to know how to get a minimal ELF file. As you see, the offset of the first section is 0x1000, which means the size of the ELF header is 4K in bytes. Is there a way to cut off the size of the header?