public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: binutils@sourceware.org
Subject: mn10300 relaxation vs got
Date: Wed, 12 Jul 2006 01:16:00 -0000	[thread overview]
Message-ID: <200607120115.k6C1Fx2x029648@greed.delorie.com> (raw)


In bfd/elf-m10300.c's mn10300_elf_relax_section(), we have this code:

      /* Try to turn a 32bit immediate, displacement or absolute address
	 into a 16bit immediate, displacement or absolute address.  */
      if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_32
	  || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOT32
	  || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOTOFF32
	  || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOTPC32)

However, GOTPC32 is not an immediate, displacement, or absolute
address.  It's a pc-relative special case.  The attached sample code
demonstrates a problem with this: relaxing can move the opcode too far
away for the relaxed value to fit (the values are carefully chosen so
that the GOT relax must happen before the others).

Why is GOTPC32 included in this part of the code?  As a cross-section
pcrel reloc, it seems to me that it would be difficult to properly
relax these, except perhaps as a single pass after everything else, so
we know these opcodes won't move any more after they've been relaxed.
Ideas?  Can we just not relax those for now?


---------- 8< ---------- dj.s ---------- 8< ----------
	.text
	.global	_start
_start:

	add	foo+32607,a0
	add	foo+32607,a0
	add	foo+32607,a0
	add	foo+32607,a0
	add	foo+32607,a0
	add	foo+32607,a0

        .LIL1:
        mov pc,a2
        add _GLOBAL_OFFSET_TABLE_+150-(.LIL1-.),a2

	nop

	.global	foo
foo:
	nop
---------- 8< ---------- dj.ld ---------- 8< ----------
OUTPUT_FORMAT("elf32-am33lin", "elf32-am33lin",
	      "elf32-am33lin")
OUTPUT_ARCH(mn10300)
ENTRY(_start)

SECTIONS
{
  /* Read-only sections, merged into text segment: */
  PROVIDE (__executable_start = 0x000000); . = 0x000000 + SIZEOF_HEADERS;
  .text           :
  {
    *(.text)
  } =0xcbcb
  . = 0x8000;
  .got            : { *(.got.plt) *(.got) }
  .data           :
  {
    *(.data)
  }
}

                 reply	other threads:[~2006-07-12  1:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200607120115.k6C1Fx2x029648@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=binutils@sourceware.org \
    /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).