public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Paul Brook <paul@codesourcery.com>
Cc: binutils@sourceware.org
Subject: Re: [patch] R_ARM_REL32 and Thumb functions.
Date: Fri, 21 Apr 2006 03:23:00 -0000	[thread overview]
Message-ID: <20060420184921.GA21343@nevyn.them.org> (raw)
In-Reply-To: <200604201929.50393.paul@codesourcery.com>

On Thu, Apr 20, 2006 at 07:29:49PM +0100, Paul Brook wrote:
> The attached patch makes the R_ARM_REL32 relocation set the low bit of the 
> value when the relocated symbol is a Thumb function, as required by the ARM 
> EABI.
> 
> I don't know if the current behavior is considered a bug or a feature for 
> pre-EABI objects. For now I'm assuming bug, and making the change 
> unconditionally. I can preserver the old behavior if anything depends on it.
> 
> A slight complication is that gas will try and fold relative expressions at 
> assembly time. This folding is done in generic code, so gets the value wrong. 
> e.g.
> 
> .thumb_func
> foo:
> .word foo - .
> 
> Will be folded to zero by gas/expr.c:expr.  I've [ab]used md_optimize_expr to 
> prevent this happening.
> 
> Initially I disabled the folding if either symbol was a Thumb function. 
> However this ends up breaking the explicit cfi directives in libgcc, so I've 
> only disabled the folding when the first symbol is a Thumb function.

Wow, this is nasty!

I can understand why Richard, and presumably the ABI, wants this to
happen:

	ldr	ip, 1f
2:	add	ip, pc, ip
	bx	ip
1:	.word	foo - . - (2b - .)

But I'd be mighty confused if, say, some code tried to copy itself from
one location to another and expected "foo - ." to describe the number
of bytes to be copied.  And now "foo - ." and ". - foo" are assymetric.


-- 
Daniel Jacobowitz
CodeSourcery

  reply	other threads:[~2006-04-20 18:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-21  3:05 Paul Brook
2006-04-21  3:23 ` Daniel Jacobowitz [this message]
2006-04-21 13:19   ` Richard Earnshaw
2006-04-21 14:36 ` Richard Earnshaw
2006-04-28 19:03   ` Paul Brook
2006-05-02 12:23     ` Nick Clifton
2006-05-02 13:20       ` Paul Brook
2006-05-02 13:36         ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060420184921.GA21343@nevyn.them.org \
    --to=drow@false.org \
    --cc=binutils@sourceware.org \
    --cc=paul@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).