This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Re: What is needed to support uclinux shared libraries on MMU-lessARM?


Bernardo Innocenti wrote:
>> And I have a question about the linker yet:
>> As we know, the high 8 bits of each item(32 bits) in GOT will identify
>> the id of the target library, But how the high 8 bits of each item in GOT
>> is set in the linker?
>
>I think elf2flt places the GOT in the FLAT binary right
>after the data section, where the BSS should be.  The
>kernel loads the whole flat file in memory and does all
>the relocations into the program text segment and in
>the libraries used by the program which are already
>"loaded" at that time.

I think the GOT of the FLAT binary file is present at the
start of the data segment(section).Per entry(item) in the
GOT contains "library id" and the offset information in
the library, just as following:

bit fields:	| 31 30...25 24 | 23 22 ... 1 0 |
			|    Lib Id     | Offset in lib |

Is it right? I have searched for the information on "shared id"
in the source code of the linker and elf2flt,but there is nothing.
So I am confused that who sets the library id in per entry in the GOT,
Is it the linker or elf2flt?

I have another question:
The linker for m68k supported linking the application
statically before, and now it can link the application with
shared library if we use the flags:
"-mid-shared-library -mshared-library-id=0"
For example:

m68k-elf-gcc -g -mid-shared-library -mshared-library-id=0 \
	        [other flags definitions and includes] \
	        -c -o myprog.o myprog.c

m68k-elf-gcc -g -o myprog \
	        -mid-shared-library -mshared-library-id=0 \
	        [other flags definitions and includes] \
	        -Wl,-elf2flt -Wl,-shared-lib-id,0 \
	        -nostartfiles ${UCLINUXDIST}/uClibc/lib/crt0.o \
	        myprog.o \
	        -Wl,-R,libmylib.gdb -lmylib

I think the flags "-mid-shared-library -mshared-library-id=0"
plays the primary function for linking the application with
shared library, but I can't find the information about the flags
"-mid-shared-library -mshared-library-id=0" in the source codes
of the linker(ld) and elf2flat.Why? and how does the linker
link the application with shared library?
What is the function of the flags "-Wl,-R,libmylib.gdb"?

>Then the BSS is cleared as usual.  If th size of the
>relocations exceeded the size of the BSS segment, that
>memory is wasted.  Well, actually that memory should
>still be available for brk(), which is implemented
>in uClinux with the restriction that it can only use
>the space wasted by the kernel allocator.
>
>The old version of malloc() in uC-libc used
>brk() until it ran out of space and then started
>allocating new blocks with mmap().
>
>The new kernel page allocator does a better job
>than the old 2's power allocator, so this trick
>has never been ported to uClibc.

Are there any relationship between the above and the GOT?

Thanks and Regards
John Lee




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