From: David Huggins-Daines <dhd@linuxcare.com>
To: Alan Modra <alan@linuxcare.com.au>
Cc: parisc-linux@thepuffingroup.com, parisc@lists.linuxcare.com
Subject: Re: Millicode calls, GP register, ld -r
Date: 11 Aug 2000 18:35:49 -0400 [thread overview]
Message-ID: <87u2crmnne.fsf@linuxcare.com> (raw)
In-Reply-To: David Huggins-Daines's message of "11 Aug 2000 16:23:56 -0400"
David Huggins-Daines <dhd@linuxcare.com> writes:
> Alan Modra <alan@linuxcare.com.au> writes:
>
> > So... I can turn a PLABEL reference into a GOT reference, which will
> > magically fix the $$dyncall problem.
>
> Yes, that's the right idea. However it only works for external
> symbols, and you still need a PLABEL32 relocation for function
> pointers to local symbols within a shared object (like dl_main for
> instance, hint hint :-)
>
> I'll try to take a shot at it but I still don't fully comprehend the
> BFD code.
Here's an (ugly) patch that works. Please verify that the last chunk
is okay - ld was outputting bogus PLABEL32 relocations when things
were compiled with -ffunction-sections, because it was effectively
calculating the addend as the offset within the input section.
With this patch ld.so manages to link itself again.
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /home/cvs/parisc/binutils-2.10/bfd/elf32-hppa.c,v
retrieving revision 1.13.2.25
diff -u -r1.13.2.25 elf32-hppa.c
--- elf32-hppa.c 2000/08/11 18:12:40 1.13.2.25
+++ elf32-hppa.c 2000/08/12 04:28:20
@@ -1058,9 +1058,14 @@
}
break;
+ case R_PARISC_PLABEL32:
+ /* In this case, if it's local, we don't need a .plt entry,
+ but we might need to generate a dynamic relocation. */
+ if (h == NULL)
+ goto local_plabel;
+
case R_PARISC_PLABEL14R: /* "Official" procedure labels. */
case R_PARISC_PLABEL21L:
- case R_PARISC_PLABEL32:
case R_PARISC_PCREL17C:
case R_PARISC_PCREL17F:
case R_PARISC_PCREL22F:
@@ -1131,6 +1136,7 @@
/* Fall through. */
#endif
+ local_plabel:
case R_PARISC_DIR32: /* .word, PARISC.unwind relocs. */
/* Flag this symbol as having a non-got, non-plt reference
@@ -2738,12 +2744,16 @@
+ hplink->sgot->output_section->vma);
break;
+ case R_PARISC_PLABEL32:
+ /* As in check_relocs, we may need to output a dynamic reloc
+ here even for local symbols. */
+ if (h == NULL)
+ goto local_plabel;
case R_PARISC_PLABEL14R:
case R_PARISC_PLABEL21L:
- case R_PARISC_PLABEL32:
if (elf_hash_table (info)->dynamic_sections_created
&& h != NULL
- && h->elf.plt.offset != -1)
+ && h->elf.plt.offset != (bfd_vma) -1)
{
/* PLABELs contain function pointers. Relocation is to
the entry for the function in the .plt. The magic +2
@@ -2756,6 +2766,7 @@
}
break;
+ local_plabel:
case R_PARISC_DIR17F:
case R_PARISC_DIR17R:
case R_PARISC_DIR14R:
@@ -2832,14 +2843,18 @@
{
int indx = 0;
+ /* Add the absolute offset of the symbol. */
+ outrel.r_addend += relocation;
+
if (! bfd_is_abs_section (sym_sec))
{
indx = elf_section_data (sym_sec->output_section)->dynindx;
- outrel.r_addend -= (sym_sec->output_offset
- + sym_sec->output_section->vma);
+ /* Subtract out the output section's address (but
+ not the offset of the input section in the
+ output section!). */
+ outrel.r_addend -= sym_sec->output_section->vma;
}
- outrel.r_addend += relocation;
outrel.r_info = ELF32_R_INFO (indx, r_type);
}
--
dhd@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.
next prev parent reply other threads:[~2000-08-12 4:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.21.0008111413410.29780-100000@front.linuxcare.com.au>
2000-08-11 7:32 ` Millicode calls, GP register, ld -r Alan Modra
2000-08-11 12:30 ` Jeffrey A Law
2000-08-11 14:56 ` Matthew Wilcox
2000-08-11 16:43 ` John David Anglin
2000-08-11 20:23 ` David Huggins-Daines
2000-08-11 22:35 ` David Huggins-Daines [this message]
2000-08-12 0:17 ` Alan Modra
2000-08-12 1:35 ` Alan Modra
2000-08-12 15:23 ` David Huggins-Daines
2000-08-12 16:07 ` John David Anglin
2000-08-12 16:29 ` David Huggins-Daines
2000-08-12 18:13 ` Jeffrey A Law
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=87u2crmnne.fsf@linuxcare.com \
--to=dhd@linuxcare.com \
--cc=alan@linuxcare.com.au \
--cc=parisc-linux@thepuffingroup.com \
--cc=parisc@lists.linuxcare.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.