Regarding linker code generation

Bhushan Verma bhushan.verma@iap-online.com
Thu Aug 2 01:21:00 GMT 2007


Thanks Nick,

I am using gnu arm tool chain 4.1.1.
I mean that when I build any shared object this toolchain is building only
one segment as below
 Program Header[0]:
     p_vaddr:      0           p_flags:    [ PF_X PF_W PF_R ]
     p_paddr:      0           p_type:     [ PT_LOAD ]
     p_filesz:     0x2bc1f     p_memsz:    0x2d6c8
     p_offset:     0           p_align:    0x8000

I know this header is needed ,but as per my knowledge this would make two
segment of p_type:PT_LOAD type.
mean two header values Program Header[0]: and  Program Header[1]: of
p_type:PT_LOAD, one for data segment and one for text segment.
why this tool chain only generate one segment . is there any thing wrong in
tool chain.

When I tried gcc3.2.2 tool chain on Linux then this makes two header.
I do not know why gcc 4.1.1 tool chain is not making two header values.


regards
verma

-----Original Message-----
From: Nick Clifton [mailto:nickc@redhat.com]
Sent: Thursday, August 02, 2007 2:39 AM
To: Bhushan Verma
Cc: binutils@sourceware.org
Subject: Re: Regarding linker code generation


Hi Verma,

> Program Header[0]:
>     p_vaddr:      0           p_flags:    [ PF_X PF_W PF_R ]
>     p_paddr:      0           p_type:     [ PT_LOAD ]
>     p_filesz:     0x2bc1f     p_memsz:    0x2d6c8
>     p_offset:     0           p_align:    0x8000
>
> Why linker is generating this type of header?

I am not sure exactly what you are asking here.  This header is needed
because
it is part of the ELF specification.  All loadable ELF binary files (ie
either
libraries or programs) have a header like this.

> But whenever I separate code and data segment this gives segmentation
fault
> inside self relocation of run time linker.

It sounds like there is a problem inside the run time linker then.

> I am using gnu arm toolchain

Are you using the latest version ?  If not then try that.  Also try building
a
toolchain from the current mainline development sources as this *may* fix
your
problem.

> Could you please help me is this due to permiison of data segment or I
have
> some other problem as in creating wrong data segment etc.

Could be.  You would need to investigate this "run time linker" you refer
to.

> could you please explian me p_vaddr Vs p_paddr.

See the ELF spec for full details.  Here is a quick excerpt:

   p_vaddr
         This member gives the virtual address at which the first byte of
         the segment resides in memory.

   p_paddr
         On systems for which physical addressing is relevant, this member
         is reserved for the segment's physical address. This member
         requires operating system specific information, which is described
         in the appendix at the end of Book III.

Cheers
   Nick




More information about the Binutils mailing list