This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[H8] Wrong offset generated for .text section


Hi, 

I have created two C applications for H8 target. 
In one application "vects.c" file has been excluded so that the output
does
not contain ".vects" section. Readelf dump of "*.out" file shows wrong
values
for offset, LMA and VMA in program header for ".text" section as shown
below.
Actually, the values present in the section header should get reflected
in 
this program 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    00000400 000054 00019e 00  AX  0   0
2
 [ 2] .debug_abbrev     PROGBITS    00000000 0001f2 000230 00      0   0
1
 [ 3] .debug_info       PROGBITS    00000000 000422 001430 00      0   0
1
 [ 4] .debug_line       PROGBITS    00000000 001852 0000bf 00      0   0
1
 [ 5] .debug_frame      PROGBITS    00000000 001914 000040 00      0   0
4
 [ 6] .debug_pubnames   PROGBITS    00000000 001954 00003f 00      0   0
1
 [ 7] .debug_aranges    PROGBITS    00000000 001993 000040 00      0   0
1
 [ 8] .debug_str        PROGBITS    00000000 0019d3 00000a 00      0   0
1
 [ 9] .comment          PROGBITS    00000000 0019dd 000064 00      0   0
1
 [10] .shstrtab         STRTAB      00000000 001a41 000087 00      0   0
1
 [11] .symtab           SYMTAB      00000000 001cd0 0003f0 10     12  42
4
 [12] .strtab           STRTAB      00000000 0020c0 000181 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)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x000000 0x000003ac 0x000003ac 0x001f2 0x001f2 R E 0x1

////////////////////////////////////////////////////////////////////////


In the other application, "vects.c" file has been included.

////////////////////////////////////////////////////////////////////////

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   00000400 0000c4 00019e 00  AX  0   0
2
 [ 2] .debug_abbrev     PROGBITS   00000000 000262 000294 00      0   0
1
 [ 3] .debug_info       PROGBITS   00000000 0004f6 0014d7 00      0   0
1
 [ 4] .debug_line       PROGBITS   00000000 0019cd 0000e7 00      0   0
1
 [ 5] .debug_frame      PROGBITS   00000000 001ab4 000040 00      0   0
4
 [ 6] .debug_pubnames   PROGBITS   00000000 001af4 000065 00      0   0
1
 [ 7] .debug_aranges    PROGBITS   00000000 001b59 000040 00      0   0
1
 [ 8] .debug_str        PROGBITS   00000000 001b99 00000a 00      0   0
1
 [ 9] .comment          PROGBITS   00000000 001ba3 000096 00      0   0
1
 [10] .vects            PROGBITS   00000000 000074 000050 00   A  0   0
4
 [11] .shstrtab         STRTAB     00000000 001c39 00008e 00      0   0
1
 [12] .symtab           SYMTAB     00000000 001ef8 000470 10     13  49
4
 [13] .strtab           STRTAB     00000000 002368 00019a 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)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x000074 0x00000000 0x00000000 0x00050 0x00050 R   0x1
  LOAD           0x0000c4 0x00000400 0x00000400 0x0019e 0x0019e R E 0x1

////////////////////////////////////////////////////////////////////////

In this case, readelf dump of "*.out" file shows correct values for
offset, 
LMA and VMA in program header for ".text" section. 

Investigation Details:

Though "bfd internals" manual says :
"Define 'ELF_MAXPAGESIZE' to the maximum size of a virtual page in
memory. 
This can normally be found at the start of chapter 5 in the processor
specific
supplement. For a processor which will only be used in an embedded
system,
or which has no memory management hardware, this can simply be '1'." 

Still it's not working. What can be the reason?

Following table summarizes the values of ELF_MAXPAGESIZE and results for
all 
the three targets (SH, H8 and M16C). 
The obtained results are for the application excluding "vects.c" file.

 Target              ELF_MAXPAGESIZE                       Result 
   SH                      0x80                            Works 
  M16C                    0x1000                           Works
   H8	                       1                         Does Not Work
   H8               0x80 (as in SH family)                 Works

Assigning this macro '1' for h8 targets, enable "includes_filehdr" and 
"includes_phdr" members of "elf segment mapping structure". This is done
in 
"elf.c" file which in turn includes elf header and program header in the

".text" section resulting in incorrect calculations of offset, LMA and
VMA.
Why program header and file header need to be included in any particular

section?

Is my understanding correct?
If yes, what value should be assigned to "ELF_MAXPAGESIZE" in 
"elf32-h8300.c" file to make above condition work ("vects.c" file
excluded)?

Regards,
Sushil Kothawade

KPIT Cummins InfoSystems Ltd.
Pune, India
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C 
and M32C Series. The following site also offers free technical support 
to its users. Visit http://www.kpitgnutools.com for details. 
Latest versions of KPIT GNU tools were released on June 1, 2007.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]