[uClibc] 0x10000 PT_LOAD Segment alignment on MIPS makes my ELF files 64 kb big

David Daney ddaney at avtrex.com
Sat Feb 5 07:57:09 UTC 2005


TINNES Julien RD-MAPS-ISS wrote:
> Hello,
> 
> I used uClibc buildroot system to build a toolchain and be able to 
> compile for a MIPS-1 R3000 big endian processor for an embeded device.
> 
> Everything worked fine, however I was surprised because the typical 
> "Hello Word" program would take more than 68 kB (dynamically linked). 
> After some research I figured out that the produced ELF executable had a 
> segment alignment of 0x10000 instead of 0x1000. Because of that my .text 
> section is padded with almost 64 kB of "0".
> 
> I supposed that the produced ld linker assumes MIPS with 64 kB-sized 
> pages (but I use 4 kB-sized page). I've not been able to find exactly 
> where it does come from. I tried to change 
> buildroot/toolchain_build_mips/linux/include/asm/page.h to #define 
> CONFIG_PAGE_SIZE_4KB and make sure PAGE_SHIFT was 12 and recompiled 
> everything but it did'nt work.
> 
> It seems that the linker would figures out the page size by using 
> getpagesize() (HAVE_GETPAGESIZE defined in config.h). I looked at 
> getpagesize() code in uClibc and it seems that it uses the auxiliary 
> vector table to get it. This auxiliary vector table is initialized with 
> the value of the auxiliary vector table on the stack when the ELF 
> program is run, which in turn comes from a field in the ELF file.
> That would mean that the used page_size is actually some field in my 
> linker's ELF binary file, but what has the linker of my linker used then ?
> But anyway mips-linux-uclibc-ld is linked against glibc not uClibc, and 
> I've not checked how getpagesize works on glibc..
> 
> Anyone has an idea?

Binutils changed this between 2.14 and 2.15.  Near the end of 
bfd/elf32-mips.c you will find the line:

#define ELF_MAXPAGESIZE			0x10000

If you change it back to 0x1000 and rebuild binutils I think it will do 
what you want.

David Daney.



More information about the uClibc mailing list