[uClinux-dev] mips and elf2flt again

Mile Davidovic Mile.Davidovic at micronasnit.com
Mon Mar 10 09:00:59 EST 2003

Hi people

I made simple "hello world" programm, and try to make flt executabile format. Platform is mips without MMU.

mips-linux-elf-gcc -fPIC -c test.c
mips-linux-elf-ld -d -r test.tmp crt0.o test.o libc.a
mips-linux-elf-ld -T elf2flt.ld -Ur -o test.elf test.tmp
mips-linux-elf-ld -T elf2flt.ld -o test.gdb test.tmp
elf2flt -r -o test.flt test.elf

In test.elf, I have next relocations: R_MIPS_26, R_MIPS_GPREL_16, R_MIPS_HI16 and R_MIPS_LO16.
I modified elf2flt to support these relocations, this is sample for R_MIPS_GPREL16 relocations:

case R_MIPS_GPREL16:
	relocation_needed = 1;
	gp0 = _bfd_get_gp_value(rel_bfd);
	gp = _bfd_get_gp_value(abs_bfd);					
	sym_vma = bfd_section_vma(abs_bfd, sym_section);				
	if ((*(q->sym_ptr_ptr))->flags & BSF_LOCAL) 
		sym_addr += ((q->addend + sym_vma + gp0 - gp) & q->howto->dst_mask);
  	   sym_addr += ((q->addend + sym_vma + gp) & q->howto->dst_mask);

Do I have to change/do something else? When I try to use this program in uCLinux I got next
output, it look like this little program try to alloc 4M ??? 
Calibrating delay loop... 107.72 BogoMIPS
Memory: 6040k/8192k available (722k kernel code, 2152k reserved, 128k data,
40k init, 0k highmem)
Dentry cache hash table entries: 1024 (order: 1, 8192 bytes)
Inode cache hash table entries: 512 (order: 0, 4096 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 2048 (order: 1, 8192 bytes)
Checking for 'wait' instruction...  unavailable.
POSIX conformance testing by UNIFIX
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
RAMDISK: romfs filesystem found at block 0
RAMDISK: Loading 66 blocks [1 disk] into ram disk... |/-\|done.
VFS: Mounted root (romfs filesystem) readonly.
Freeing unused kernel memory: 40k freed
BINFMT_FLAT: Loading file: /sbin/init
Allocation of length 4199194 from process 1 failed
Buffer memory:       12kB
Cache memory:       60kB
Free pages:        5796kB (     0kB HighMem)
Zone:DMA freepages:     0kB min:     0kB low:     0kB high:     0kB
Zone:Normal freepages:  5796kB min:    80kB low:   160kB high:   240kB
Zone:HighMem freepages:     0kB min:     0kB low:     0kB high:     0kB
( Active: 3, inactive: 15, free: 1449 )
= 0kB)
1*4kB 0*8kB 0*16kB 1*32kB 0*64kB 1*128kB 0*256kB 1*512kB 1*1024kB 0*2048kB
1*4096kB = 5796kB)
= 0kB)
Unable to allocate RAM for process text/data, errno 12


More information about the uClinux-dev mailing list