This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: 16-bit relocations in 32-bit code


What about something like this?
This is all constant expressions requiring no relocations,
regardless of the actual addresses.
Assuming it's all in the same section and file of course.

tab:
	.short PLUS-START
	.short MINUS-START
	.short TIMES-START
...
START:
	# index by edi and add START address to offset
	movzwl tab(%edi,%edi),%edi
	addl $START,%edi
	jmp *%edi

PLUS:
MINUS:
TIMES:

-Anders

On 2010-03-15, at 23:43 , Andrew Zabolotny wrote:

> From Mon, 15 Mar 2010 12:44:26 -0700
> Richard Henderson <rth@redhat.com> wrote:
> 
>> There is no solution that is generally portable.
> I understand, but I can live with platform-specific macros.
> 
>> However, given the existance of R_386_PC16, you should be able to
>> represent ".short SYM-." for any SYM on both i386 and x86_64.
> I don't quite get the idea. ".short SYM-." won't generate any
> relocation at all, how this can help me? But I tried a simple example
> like this:
> 
>     .reloc  .,R_386_PC16,PLUS
>     .short  0
> 
> and this at least does not generate the linker warning about overflow.
> Can I turn my initial statement:
> 
> 	.short	PLUS-0x610000
> 
> into a PC16 relocation somehow?
> 
> Some platforms support the modificator lo16(addr). This is the ideal
> solution for my problem; unfortunately, i386 does not support it.
> 
>> For portability to other machines, you might consider writing
>> your own trivial assembler and linker for the forth.  You
>> can then include the linked forth program into the native 
>> binary via .incbin or the like.
> That's what I'm trying to avoid by using binutils as the swiss army
> knife :)
> 
> -- 
> Andrew


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