public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* simplest way to get the size of an output section
@ 2004-10-04  9:51 Etienne Lorrain
  2004-10-04 12:51 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Etienne Lorrain @ 2004-10-04  9:51 UTC (permalink / raw)
  To: binutils

  Hello,

  On a Linux ia32 system, I am trying to get the size of an output
 section of an ELF file to use it automatically in a Makefile.

 Ideally I would like to compile a small GCC program like:
gcc -Wl,--defsym,linker_tells_size=SIZEOF(.text16) print_command_line.c
 but that will not work because --defsym cannot get the SIZEOF().

 So I have gone the objcopy way:
objcopy --output-target binary --only-section .text16 vmlinux param.bin
./print_command_line ` cat param.bin | wc -c `
 That does the job, but is there a way to not create the temporary file
 "param.bin" (i.e. objcopy uses standard output) (because it is always
 a problem in Makefiles: it may already exist and be write protected,
 it needs to be cleaned by make clean, an interrupted make command
 may leave the temporary file...) or another way, without using too
 complex awk or sed scripts?

  Thank you,
  Etienne.


	

	
		
Vous manquez dÂ’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest way to get the size of an output section
  2004-10-04  9:51 simplest way to get the size of an output section Etienne Lorrain
@ 2004-10-04 12:51 ` Daniel Jacobowitz
  2004-10-04 14:06   ` Etienne Lorrain
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-10-04 12:51 UTC (permalink / raw)
  To: Etienne Lorrain; +Cc: binutils

On Mon, Oct 04, 2004 at 11:51:01AM +0200, Etienne Lorrain wrote:
>   Hello,
> 
>   On a Linux ia32 system, I am trying to get the size of an output
>  section of an ELF file to use it automatically in a Makefile.
> 
>  Ideally I would like to compile a small GCC program like:
> gcc -Wl,--defsym,linker_tells_size=SIZEOF(.text16) print_command_line.c
>  but that will not work because --defsym cannot get the SIZEOF().
> 
>  So I have gone the objcopy way:
> objcopy --output-target binary --only-section .text16 vmlinux param.bin
> ./print_command_line ` cat param.bin | wc -c `
>  That does the job, but is there a way to not create the temporary file
>  "param.bin" (i.e. objcopy uses standard output) (because it is always
>  a problem in Makefiles: it may already exist and be write protected,
>  it needs to be cleaned by make clean, an interrupted make command
>  may leave the temporary file...) or another way, without using too
>  complex awk or sed scripts?

Why not use objdump -h or readelf -S?

-- 
Daniel Jacobowitz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest way to get the size of an output section
  2004-10-04 12:51 ` Daniel Jacobowitz
@ 2004-10-04 14:06   ` Etienne Lorrain
  2004-10-04 14:59     ` Paul Brook
  0 siblings, 1 reply; 5+ messages in thread
From: Etienne Lorrain @ 2004-10-04 14:06 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: binutils

 --- Daniel Jacobowitz <drow@false.org> a écrit : 
> On Mon, Oct 04, 2004 at 11:51:01AM +0200, Etienne Lorrain wrote:
> >   On a Linux ia32 system, I am trying to get the size of an output
> >  section of an ELF file to use it automatically in a Makefile.
> > 
> >  Ideally I would like to compile a small GCC program like:
> > gcc -Wl,--defsym,linker_tells_size=SIZEOF(.text16) print_command_line.c
> >  but that will not work because --defsym cannot get the SIZEOF().
> > 
> >  So I have gone the objcopy way:
> > objcopy --output-target binary --only-section .text16 vmlinux param.bin
> > ./print_command_line ` cat param.bin | wc -c `
> >  That does the job, but is there a way to not create the temporary file
> >  "param.bin" (i.e. objcopy uses standard output) (because it is always
> >  a problem in Makefiles: it may already exist and be write protected,
> >  it needs to be cleaned by make clean, an interrupted make command
> >  may leave the temporary file...) or another way, without using too
> >  complex awk or sed scripts?
> 
> Why not use objdump -h or readelf -S?

  Basically because of the complexity of the sed or awk to get back the 
 hexadecimal number (in a Makefile):
 readelf gives all the sections, so (not tested - not a real awk master)
./print_command_line ` readelf -S vmlinux | awk "/.text16/ {printf $...}" `
 objdump - when I tried yesterday - wanted the number of the input
 section and need quite a complex filtering of the standard output too.

  These tools were not done to be used in a Makefile.
  Etienne.


	

	
		
Vous manquez dÂ’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest way to get the size of an output section
  2004-10-04 14:06   ` Etienne Lorrain
@ 2004-10-04 14:59     ` Paul Brook
  2004-10-04 15:36       ` Etienne Lorrain
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Brook @ 2004-10-04 14:59 UTC (permalink / raw)
  To: binutils; +Cc: Etienne Lorrain

On Monday 04 October 2004 15:06, Etienne Lorrain wrote:
>  --- Daniel Jacobowitz <drow@false.org> a écrit :
> > On Mon, Oct 04, 2004 at 11:51:01AM +0200, Etienne Lorrain wrote:
> > >   On a Linux ia32 system, I am trying to get the size of an output
> > >  section of an ELF file to use it automatically in a Makefile.
> > >
> > >  Ideally I would like to compile a small GCC program like:
> > > gcc -Wl,--defsym,linker_tells_size=SIZEOF(.text16) print_command_line.c
> > >  but that will not work because --defsym cannot get the SIZEOF().
> > >
> > >  So I have gone the objcopy way:
> > > objcopy --output-target binary --only-section .text16 vmlinux param.bin
> > > ./print_command_line ` cat param.bin | wc -c `
> > >  That does the job, but is there a way to not create the temporary file
> > >  "param.bin" (i.e. objcopy uses standard output) (because it is always
> > >  a problem in Makefiles: it may already exist and be write protected,
> > >  it needs to be cleaned by make clean, an interrupted make command
> > >  may leave the temporary file...) or another way, without using too
> > >  complex awk or sed scripts?
> >
> > Why not use objdump -h or readelf -S?
>
>   Basically because of the complexity of the sed or awk to get back the
>  hexadecimal number (in a Makefile):
>  readelf gives all the sections, so (not tested - not a real awk master)
> ./print_command_line ` readelf -S vmlinux | awk "/.text16/ {printf $...}" `
>  objdump - when I tried yesterday - wanted the number of the input
>  section and need quite a complex filtering of the standard output too.

How about "size -A"

Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest way to get the size of an output section
  2004-10-04 14:59     ` Paul Brook
@ 2004-10-04 15:36       ` Etienne Lorrain
  0 siblings, 0 replies; 5+ messages in thread
From: Etienne Lorrain @ 2004-10-04 15:36 UTC (permalink / raw)
  To: binutils; +Cc: Paul Brook

 --- Paul Brook <paul@codesourcery.com> a écrit : 
> On Monday 04 October 2004 15:06, Etienne Lorrain wrote:
> >  --- Daniel Jacobowitz <drow@false.org> a écrit :
> > > On Mon, Oct 04, 2004 at 11:51:01AM +0200, Etienne Lorrain wrote:
> > > >
> > > >   On a Linux ia32 system, I am trying to get the size of an output
> > > >  section of an ELF file to use it automatically in a Makefile.
> > > >
> > > >  Ideally I would like to compile a small GCC program like:
> > > > gcc -Wl,--defsym,linker_tells_size=SIZEOF(.text16)
print_command_line.c
> > > >  but that will not work because --defsym cannot get the SIZEOF().
> > > >
> > > >  So I have gone the objcopy way:
> > > > objcopy --output-target binary --only-section .text16 vmlinux
> param.bin
> > > > ./print_command_line ` cat param.bin | wc -c `
> > > >  That does the job, but is there a way to not create the temporary
file
> > > >  "param.bin" (i.e. objcopy uses standard output) (because it is
always
> > > >  a problem in Makefiles: it may already exist and be write
protected,
> > > >  it needs to be cleaned by make clean, an interrupted make command
> > > >  may leave the temporary file...) or another way, without using too
> > > >  complex awk or sed scripts?
> > >
> > > Why not use objdump -h or readelf -S?
> >
> >   Basically because of the complexity of the sed or awk to get back the
> >  hexadecimal number (in a Makefile):
> >  readelf gives all the sections, so (not tested - not a real awk master)
> > ./print_command_line ` readelf -S vmlinux | awk "/.text16/ {printf
$...}" `
> >  objdump - when I tried yesterday - wanted the number of the input
> >  section and need quite a complex filtering of the standard output too.
> 
> How about "size -A"

  Thank you, that does the trick (from command line):
./print_command_line ` size -A vmlinux | grep .text16 | awk " { print \$2 }
" `

  Etienne.


	

	
		
Vous manquez dÂ’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-04 15:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-04  9:51 simplest way to get the size of an output section Etienne Lorrain
2004-10-04 12:51 ` Daniel Jacobowitz
2004-10-04 14:06   ` Etienne Lorrain
2004-10-04 14:59     ` Paul Brook
2004-10-04 15:36       ` Etienne Lorrain

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).