* [GOLD] question about gold handling SPARC style .rela.plt, .rela.plt overlapping
@ 2012-08-07 10:25 WANG.Jiong
2012-08-07 13:34 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: WANG.Jiong @ 2012-08-07 10:25 UTC (permalink / raw)
To: davem, iant; +Cc: binutils
Hi David & Ian,
currently, I am porting gold linker for a private target which allow
PLTREL overlapping
so, I met exactly the same problem as you have discussed two years ago
http://sourceware.org/ml/binutils/2010-02/msg00140.html
I see you have done a fix with the following logic:
1. .rela.dyn, .rela.plt are seperate
2. generate DT_RELA only when there is .rela.dyn, and DT_RELASZ be
the total size of both .rela.dyn and .rela.plt
But, If there is no .rela.dyn, without DT_RELA, it seems dynamic
linker behave incorrectly when ELF_MACHINE_PLTREL_OVERLAP defined
I checked the implementation of _ELF_DYNAMIC_DO_RELOC in glib
elf/dynamic-link.h:260
# define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy,
skip_ifunc, test_rel)
without DT_REL or DT_RELA, ranges[0] are not initialized properly.
So, should we always generate DT_RELA, DT_RELASZ, DT_RELAENT, and
make DT_RELA, DT_RELASZ exactly the same value as DT_JMPREL, DT_PLTRELSZ ?
that is, for the following condition check in
Layout::add_target_dynamic_tags
4344 if (dyn_rel != NULL && dyn_rel->output_section() != NULL)
4345 {
4346 odyn->add_section_address(use_rel ? elfcpp::DT_REL :
elfcpp::DT_RELA,
4347 dyn_rel->output_section());
4348 if (plt_rel != NULL
4349 && plt_rel->output_section() != NULL
4350 && dynrel_includes_plt)
should we check dynrel_includes_plt even when dyn_rel == NULL ?
or I have misunderstood something ?
thanks very much
---
Regards,
WANG.Jiong
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GOLD] question about gold handling SPARC style .rela.plt, .rela.plt overlapping
2012-08-07 10:25 [GOLD] question about gold handling SPARC style .rela.plt, .rela.plt overlapping WANG.Jiong
@ 2012-08-07 13:34 ` Ian Lance Taylor
2012-08-07 14:19 ` Jiong WANG
0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2012-08-07 13:34 UTC (permalink / raw)
To: WANG.Jiong; +Cc: davem, binutils
[-- Attachment #1: Type: text/plain, Size: 1141 bytes --]
On Tue, Aug 7, 2012 at 1:24 AM, WANG.Jiong <wong.kwongyuan@gmail.com> wrote:
>
> currently, I am porting gold linker for a private target which allow
> PLTREL overlapping
>
> ...
>
> So, should we always generate DT_RELA, DT_RELASZ, DT_RELAENT, and make
> DT_RELA, DT_RELASZ exactly the same value as DT_JMPREL, DT_PLTRELSZ ?
>
> that is, for the following condition check in
> Layout::add_target_dynamic_tags
>
> 4344 if (dyn_rel != NULL && dyn_rel->output_section() != NULL)
> 4345 {
> 4346 odyn->add_section_address(use_rel ? elfcpp::DT_REL :
> elfcpp::DT_RELA,
> 4347 dyn_rel->output_section());
> 4348 if (plt_rel != NULL
> 4349 && plt_rel->output_section() != NULL
> 4350 && dynrel_includes_plt)
>
> should we check dynrel_includes_plt even when dyn_rel == NULL ?
Yes, I agree. If dynrel_includes_plt && dyn_rel == NULL && plt_rel !=
NULL, we should generate the DT_REL tags.
I committed the attached patch.
Ian
2012-08-07 Ian Lance Taylor <iant@google.com>
* layout.cc (Layout::add_target_dynamic_tags): If
dynrel_includes_plt but no dyn_rel, emit dynamic reloc tags for
plt_rel.
[-- Attachment #2: foo.diff --]
[-- Type: application/octet-stream, Size: 2107 bytes --]
Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.231
retrieving revision 1.232
diff -u -p -r1.231 -r1.232
--- layout.cc 22 Jun 2012 18:02:24 -0000 1.231
+++ layout.cc 7 Aug 2012 13:24:47 -0000 1.232
@@ -4341,19 +4341,26 @@ Layout::add_target_dynamic_tags(bool use
use_rel ? elfcpp::DT_REL : elfcpp::DT_RELA);
}
- if (dyn_rel != NULL && dyn_rel->output_section() != NULL)
+ if ((dyn_rel != NULL && dyn_rel->output_section() != NULL)
+ || (dynrel_includes_plt
+ && plt_rel != NULL
+ && plt_rel->output_section() != NULL))
{
+ bool have_dyn_rel = dyn_rel != NULL && dyn_rel->output_section() != NULL;
+ bool have_plt_rel = plt_rel != NULL && plt_rel->output_section() != NULL;
odyn->add_section_address(use_rel ? elfcpp::DT_REL : elfcpp::DT_RELA,
- dyn_rel->output_section());
- if (plt_rel != NULL
- && plt_rel->output_section() != NULL
- && dynrel_includes_plt)
- odyn->add_section_size(use_rel ? elfcpp::DT_RELSZ : elfcpp::DT_RELASZ,
+ (have_dyn_rel
+ ? dyn_rel->output_section()
+ : plt_rel->output_section()));
+ elfcpp::DT size_tag = use_rel ? elfcpp::DT_RELSZ : elfcpp::DT_RELASZ;
+ if (have_dyn_rel && have_plt_rel && dynrel_includes_plt)
+ odyn->add_section_size(size_tag,
dyn_rel->output_section(),
plt_rel->output_section());
+ else if (have_dyn_rel)
+ odyn->add_section_size(size_tag, dyn_rel->output_section());
else
- odyn->add_section_size(use_rel ? elfcpp::DT_RELSZ : elfcpp::DT_RELASZ,
- dyn_rel->output_section());
+ odyn->add_section_size(size_tag, plt_rel->output_section());
const int size = parameters->target().get_size();
elfcpp::DT rel_tag;
int rel_size;
@@ -4379,7 +4386,7 @@ Layout::add_target_dynamic_tags(bool use
}
odyn->add_constant(rel_tag, rel_size);
- if (parameters->options().combreloc())
+ if (parameters->options().combreloc() && have_dyn_rel)
{
size_t c = dyn_rel->relative_reloc_count();
if (c > 0)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GOLD] question about gold handling SPARC style .rela.plt, .rela.plt overlapping
2012-08-07 13:34 ` Ian Lance Taylor
@ 2012-08-07 14:19 ` Jiong WANG
0 siblings, 0 replies; 3+ messages in thread
From: Jiong WANG @ 2012-08-07 14:19 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: davem, binutils
Thanks!
---
Regards,
WANG.Jiong
2012/8/7 Ian Lance Taylor <iant@google.com>:
> On Tue, Aug 7, 2012 at 1:24 AM, WANG.Jiong <wong.kwongyuan@gmail.com> wrote:
>>
>> currently, I am porting gold linker for a private target which allow
>> PLTREL overlapping
>>
>> ...
>>
>> So, should we always generate DT_RELA, DT_RELASZ, DT_RELAENT, and make
>> DT_RELA, DT_RELASZ exactly the same value as DT_JMPREL, DT_PLTRELSZ ?
>>
>> that is, for the following condition check in
>> Layout::add_target_dynamic_tags
>>
>> 4344 if (dyn_rel != NULL && dyn_rel->output_section() != NULL)
>> 4345 {
>> 4346 odyn->add_section_address(use_rel ? elfcpp::DT_REL :
>> elfcpp::DT_RELA,
>> 4347 dyn_rel->output_section());
>> 4348 if (plt_rel != NULL
>> 4349 && plt_rel->output_section() != NULL
>> 4350 && dynrel_includes_plt)
>>
>> should we check dynrel_includes_plt even when dyn_rel == NULL ?
>
> Yes, I agree. If dynrel_includes_plt && dyn_rel == NULL && plt_rel !=
> NULL, we should generate the DT_REL tags.
>
> I committed the attached patch.
>
> Ian
>
> 2012-08-07 Ian Lance Taylor <iant@google.com>
>
> * layout.cc (Layout::add_target_dynamic_tags): If
> dynrel_includes_plt but no dyn_rel, emit dynamic reloc tags for
> plt_rel.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-07 14:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-07 10:25 [GOLD] question about gold handling SPARC style .rela.plt, .rela.plt overlapping WANG.Jiong
2012-08-07 13:34 ` Ian Lance Taylor
2012-08-07 14:19 ` Jiong WANG
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).