This is the mail archive of the binutils@sources.redhat.com 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]

ld - adding sessions to the program header


Hello.

I'm trying to change the linker behavior to create extra sessions after
.bss, and map them to the process memory.

I've suceeded in adding arbitrary data into the session header table,
and setting the VMA and size of the session.

But when adding those sessions to the program header table, the linker
always map the refeering session to address 0, no matter the address of
the session header table.

I've modified the ld default script to do the job, like this:

PHDRS
{
  headers PT_PHDR PHDRS 
	FLAGS ( 5 ) ;
  interp PT_INTERP ;
  text PT_LOAD FILEHDR PHDRS ;
  data PT_LOAD ;
  dynamic PT_DYNAMIC ;
==================================
begin of 2 program header entries:
==================================
  test1 PT_LOAD
 	FLAGS ( 5 ) ;
  test2 PT_LOAD
 	FLAGS ( 0 ) ;
==================================
end of 2 program header entries.
==================================

  note PT_NOTE ;
}

SECTIONS
{
===============================
.text, .data, .bss & others (ommited)
===============================
  .test1 ALIGN(0x1000) : { . = 0x300 ; . = ALIGN(0x1000) ; } :test1
=0x01234567
  .test2 ALIGN(0x1000) : { . = 0x200 ; . = ALIGN(0x1000) ; } :test2
=0x01234567
===============================
debugging data  (ommited also)
===============================
}

But the result wasn't the expected, 2 program header entries where
created:

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  PHDR           0x000034 0x08048034 0x08048034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x08048134 0x08048134 0x00034 0x00034 R   0x4
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x0044c 0x0044c R E
0x1000
  LOAD           0x00044c 0x0804944c 0x0804944c 0x00100 0x00104 RW 
0x1000
  DYNAMIC        0x000458 0x08049458 0x08049458 0x000c8 0x000c8 RW  0x4
==========CREATED================================
  LOAD           0x00054c 0x00000000 0x00000000 0x00000 0x00000 R E
0x1000
  LOAD           0x00054c 0x00000000 0x00000000 0x00000 0x00000    
0x1000
== BUT whith empty VMA & sizes , wrong offset=====
  NOTE           0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4

and the session header table was just fine (except the align value):
Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg
Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00     
0   0  0
 =================ETC=========
  [23] .test1        PROGBITS        0804a000 00054c 001000 00   W  0  
0  1
  [24] .test2        PROGBITS        0804b000 00154c 001000 00   W  0  
0  1
 =================ETC=========

What I'm doing wrong?

Thank's in advance,
-- 
Guilherme Destefani
Computer Engineer
Helix S.A.
gd _at_ helixbrasil _dot_ com _dot_ br
Brazil - Parana - Curitiba
(+5541) 362-1313


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