This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] [RFC] nios2: Fix initial PLT entry population
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: Marek Vasut <marex at denx dot de>
- Cc: <binutils at sourceware dot org>, Chung-Lin Tang <cltang at codesourcery dot com>, Ley Foon Tan <lftan dot linux at gmail dot com>, Thomas Chou <thomas at wytron dot com dot tw>
- Date: Tue, 8 Dec 2015 09:43:50 -0700
- Subject: Re: [PATCH] [RFC] nios2: Fix initial PLT entry population
- Authentication-results: sourceware.org; auth=none
- References: <1448723082-6208-1-git-send-email-marex at denx dot de> <565D2BE7 dot 4050304 at codesourcery dot com> <201512011416 dot 51024 dot marex at denx dot de> <201512081727 dot 58364 dot marex at denx dot de>
On 12/08/2015 09:27 AM, Marek Vasut wrote:
On Tuesday, December 01, 2015 at 02:16:50 PM, Marek Vasut wrote:
On Tuesday, December 01, 2015 at 06:11:03 AM, Sandra Loosemore wrote:
On 11/30/2015 07:46 AM, Marek Vasut wrote:
I can do that, but I didn't find the bug in bugzilla. Shall I create a
new one? In the meantime, I pushed the whole tarball from the build to
[1], sha1sum is fe62b3848edf51b6083ca53f861c3dd3af49dd4b
orc-0.4.23-r0.tar.xz
You can find the entire build log in
orc-0.4.23-r0/temp/log.do_compile.7916 , the objects are located in
orc-0.4.23-r0/build/ directory and the source is in the
orc-0.4.23-r0/orc-0.4.23/ directory.
[1] http://www.bfuser.eu/orc-0.4.23-r0.tar.xz
I took a look at this, but it seems the set of objects is not complete
(e.g., it's missing the sysroot you are linking against). If I get you
a patch that I'm more confident is correct, would you be able to test it
on this example?
Of course, I'd be happy to help.
I can also show you how to prepare the OpenEmbedded/Yocto build for NIOS2,
so you can fiddle with it yourself, but that might be a longer process.
Please let me know.
Hi,
any news on this please ?
Sorry, I got distracted last week and just finished regression testing
overnight. Does the attached patch solve your problem?
-Sandra
2015-12-08 Sandra Loosemore <sandra@codesourcery.com>
bfd/
* elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Correct
%hiadj/%lo computations for _GLOBAL_OFFSET_TABLE_ in initial
PLT entries. Assert alignment requirements.
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index 6b29d8b..1c54320 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -5383,12 +5383,17 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd,
+ sgotplt->output_offset);
if (bfd_link_pic (info))
{
- bfd_vma corrected = got_address - (splt->output_section->vma
- + splt->output_offset + 4);
+ bfd_vma got_pcrel = got_address - (splt->output_section->vma
+ + splt->output_offset);
+ /* Both GOT and PLT must be aligned to a 16-byte boundary
+ for the two loads to share the %hiadj part. The 4-byte
+ offset for nextpc is accounted for in the %lo offsets
+ on the loads. */
+ BFD_ASSERT ((got_pcrel & 0xf) == 0);
nios2_elf32_install_data (splt, nios2_so_plt0_entry, 0, 6);
- nios2_elf32_install_imm16 (splt, 4, hiadj (corrected));
- nios2_elf32_install_imm16 (splt, 12, (corrected & 0xffff) + 4);
- nios2_elf32_install_imm16 (splt, 16, (corrected & 0xffff) + 8);
+ nios2_elf32_install_imm16 (splt, 4, hiadj (got_pcrel));
+ nios2_elf32_install_imm16 (splt, 12, got_pcrel & 0xffff);
+ nios2_elf32_install_imm16 (splt, 16, (got_pcrel + 4) & 0xffff);
}
else
{
@@ -5404,6 +5409,10 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd,
6 | ((res_size - (res_offset + 4)) << 6),
splt->contents + res_offset);
+ /* The GOT must be aligned to a 16-byte boundary for the
+ two loads to share the same %hiadj part. */
+ BFD_ASSERT ((got_address & 0xf) == 0);
+
nios2_elf32_install_data (splt, nios2_plt0_entry, res_size, 7);
nios2_elf32_install_imm16 (splt, res_size, hiadj (res_start));
nios2_elf32_install_imm16 (splt, res_size + 4,
@@ -5411,9 +5420,9 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd,
nios2_elf32_install_imm16 (splt, res_size + 12,
hiadj (got_address));
nios2_elf32_install_imm16 (splt, res_size + 16,
- (got_address & 0xffff) + 4);
+ (got_address + 4) & 0xffff);
nios2_elf32_install_imm16 (splt, res_size + 20,
- (got_address & 0xffff) + 8);
+ (got_address + 8) & 0xffff);
}
}
}