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: Relocations on branches


Hi DJ,

Thanks for your quick answer.

On Wed, Apr 15, 2009 at 10:40 PM, DJ Delorie <dj@redhat.com> wrote:
> Whether a branch uses absolute or pc-rel addressing depends entirely
> on the chip, not binutils. ?Just because binutils has internal
> relocation types for pc-rel doesn't mean the chip supports them.

Yes, I didn't take that into account. What I really meant was in chips
that support PC-rel addressing.

> However, in your example, you're missing a point - the chip *does*
> support pc-rel addressing, but the address has already been resolved
> by the *assembler*, which is why there's no relocation record in the
> object.

That's the point. The address is resolved, so no relocation record,
but I want one there.
The reason is that I am working in a memory system optimization tool
that may insert instructions in the middle of some code, thus changing
offsets of PC-rel branch instructions. If I can get relocation records
for these, I won't need to fix them myself, the linker can do it for
me for free.

So I have two main ideas, in order of preference:

1) Instruct the assembler, compiler, or whoever-that-is not to resolve
the address, thus leaving the relocation records in the object?

2) Write a tool that uses libbfd to get the contents of each section,
identify branches and create PC-rel relocations for each of them.

Then my optimization tool could do its job, insert instructions in the
right places, and the linker do its magic to leave the branches
smooth.

> If the chip you're using supports linker relaxation, try enabling it -
> that often causes such relocations to be deferred to the linker, so
> you can see what they are.

I don't know a thing about linker relaxation. Does it fits in the idea
1? And if so,
<dumb_question_mode>
How do I enable it for a MIPS architecture, for example?
</dumb_question_mode>

Cheers,
Daniel


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