[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] avr-objcopy not copying custom section...

From: Erik Christiansen
Subject: Re: [avr-gcc-list] avr-objcopy not copying custom section...
Date: Wed, 25 May 2011 23:11:43 +1000
User-agent: Mutt/1.5.20 (2009-06-14)

On 25.05.11 18:55, Boyapati, Anitha wrote:
> >On 26.02.11 20:22, Boyapati, Anitha wrote:

> >>
> >> Actually, looking back, I don’t get the meaning of this.
> Erik wrote:
> >Having just now seen this post, I'll offer the following thoughts.


> >> How can a section be ‘executable’ without being ‘allocatable’ in ELF?
> >
> >An overlay would fit that case. 
> Ok! This is interesting.
> > Perhaps the question relates instead to
> >the ELF format's ability to distinguish the cases. OK, the p_flags
> >member of the Phdr struct only provides for X, W, and R in its bitmask,
> >according to the elf manpage, so the question seems fair. 
> Yes. That is where the confusion stemmed from.

Hi Anitha,

Last time, I didn't look exhaustively for flags in the ELF format. With
the aid of "readelf -e test.elf", we can see that there are more section
flags in the section header:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        00000000 000094 00003a 00  AX  0   0  1
  [ 2] .data             PROGBITS        00800100 0000ce 000000 00  WA  0   0  1
  [ 3] .bss              NOBITS          00800100 0000ce 000000 00  WA  0   0  1
  [ 4] .noinit           PROGBITS        00800100 0000ce 000000 00   W  0   0  1
  [ 5] .eeprom           PROGBITS        00810000 0000ce 000000 00   W  0   0  1
  [ 6] .shstrtab         STRTAB          00000000 0000ce 00003c 00      0   0  1
  [ 7] .symtab           SYMTAB          00000000 000274 0002a0 10      8  28  4
  [ 8] .strtab           STRTAB          00000000 000514 000146 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

I overlooked that before. In the sh_flags member of the Shdr struct, the
ELF format does have separate explicit alloc and execute flags.


> 'objdump' program works on BFD structures. The set of BFD section
> flags for a super set to ELF section flags. So, the dump of section
> headers shows BFD flags but not ELF flags.

But it is an ELF file that we are dumping, so any explicit flags we read
must be in the ELF format. I just forgot about section headers, and
didn't look for sh_flags, and that's where the "missing" flags reside,


> >The only mystery seems to be whether any of these flags used earlier
> >in the toolchain become implicit in the ELF file, but that's just an
> >implementation detail.
> >

> I agree that there is an independence of attributes to certain extent.
> But this information pushed my curiosity further on how attributes are
> calculated for user-defined sections. I dug a little more. Binutils
> seems to work out the permutations and combinations of them.

> For e.g, as you pointed out .eeprom has CONTENTS but is not 'ALLOC'.
> Obviously, this involves lot of implementation detail that possibly
> considers 'size' of the section to make it ALLOC. Since the size is 0,
> the .eeprom section is not ALLOC. (Making it CONTENTS is a little but
> may be that is default. I am sorry but this is just my wild guess, I
> could be wrong.)

Yes, ALLOC could in practical terms be implict, I agree, but the
SHF_ALLOC bit in sh_flags makes it explicit in ELF, we now see.


> I find this useful. 
> http://ftp.gnu.org/pub/old-gnu/Manuals/bfd-2.9.1/html_node/bfd_13.html 

Thanks for the link. I've had a look around, and will read more on return
from a week on the family farm. (From tomorrow. Tools will be chainsaw
and bulldozer, not gnu tools.)

> Thanks for sharing your thoughts on overlays.

You are most welcome. After more than a quarter of a century of embedded
development, it is more interesting to explore odd corners of the
toolchain than it is to do yet more code development. (Though I still
enjoy tweaking linker scripts for odd cases.)


"We've found that people are signing contracts and a couple of years
down the road looking back and thinking the equity in my home is being
eaten away severely and obviously it is because of the compounding
interest," she added. [Describing Reverse Mortgages]
                 - http://abc.com.au/news/stories/2011/05/25/3226833.htm

reply via email to

[Prev in Thread] Current Thread [Next in Thread]