Re: [uClinux-dev] elf2flt

From: Joe deBlaquiere (jadb@redhat.com)
Date: Sun Jan 28 2001 - 19:08:25 EST


A few things I would look for to start with just to be sure

1. Compile a few simple (fully resolved) programs and dump the 
relocation entries just to make sure you're getting the relocations you 
would expect. I would suggest linking your program using "ld" and then 
using "ld -r". If you don't get the same relocation entries, then you 
need to understand why. Most likely this means that something should 
have been relocatable but was assigned a fixed address (not good) in the 
final actions of the linker.

2. Pay close attention to the data relocation entries for initialized 
pointers. In the example below, a & b should be allocated to the .bss 
segment, c should be allocated to the .data segment, and the data values 
written to c should have data relocations.

static int a;
static int b;
static int *c[2] = { &a, &b } ;

3. Check into the handling of unresolved weak symbols. Weak references 
which remain unresolved should not be generating relocation entries. The 
value of these symbols when interpreted as data should be zero, and if a 
relocation entry is generated, the value will be nonzero.

extern int *pWeakExtern __attribute__ ((weak)) ;

int TestWeakExtern()
{
	if (pWeakExtern)
	{
		return -1 ;
	}
	
	return 0 ;
}

These are of course the significant problems I encountered with trying 
to generate a correct FLAT executable (or at least the ones I remember 
right off the top of my head). I'm sure I'm missing something, but 
hopefully you get the general picture.

--
Joe

FAZIO,VINCENT (Non-HP-Australia,ex2) wrote:

> I'm thinking about modifying the elf2flt program from 68k-specific to
> Hitachi SH-specific. I've looked at the code, there is nothing much to
> change except for linking in the correct bfd library and modifying the 68k
> relocations to be SH-specific. 
> 
> Does anyone know if there's anything else I should be doing?
> 
> I have noticed that the code doesn't transfer the .rodata section of the ELF
> file into the FLT file. Anyone know why this is so?
> 

Kinda sounds like a bug to me, but that would be surprising. I believe 
the original intention was to transfer the .rodata section to the end of 
the code segment so that it could be burned into ROM, but it might have 
been glommed on the end of .data instead. Are you sure it's not doing that?

> Thanks.
> 
> Vincent Fazio
> This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/


-- 
Joe deBlaquiere
Red Hat, Inc.
307 Wynn Drive
Huntsville AL, 35805
voice : (256)-704-9200
fax   : (256)-837-3839

This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/


This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:19:28 EDT