public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "PRC" <panruochen@gmail.com>
To: binutils <binutils@sourceware.org>
Subject: How to inform the linker not to produce any data for a .bss section?
Date: Sun, 09 Dec 2007 02:51:00 -0000	[thread overview]
Message-ID: <200712091050318718404@gmail.com> (raw)

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?

             reply	other threads:[~2007-12-09  2:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-09  2:51 PRC [this message]
2007-12-09 20:07 ` Daniel Jacobowitz
2007-12-11  1:19   ` Re: How to inform the linker not to produce any data for a .bsssection? PRC
2007-12-11 12:59     ` Daniel Jacobowitz
2007-12-12  9:08       ` Dave Murphy
2007-12-12 14:19         ` Daniel Jacobowitz
2007-12-18 10:19       ` Re: Re: How to inform the linker not to produce any data for a.bsssection? PRC
2007-12-18 11:34         ` Ivan Pulleyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200712091050318718404@gmail.com \
    --to=panruochen@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).