Discussion:
[GOLD] question about gold handling SPARC style .rela.plt, .rela.plt overlapping
WANG.Jiong
2012-08-07 08:24:42 UTC
Permalink
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
Ian Lance Taylor
2012-08-07 13:25:36 UTC
Permalink
Post by WANG.Jiong
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 {
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 <***@google.com>

* layout.cc (Layout::add_target_dynamic_tags): If
dynrel_includes_plt but no dyn_rel, emit dynamic reloc tags for
plt_rel.
Jiong WANG
2012-08-07 14:07:36 UTC
Permalink
Thanks!

---
Regards,
WANG.Jiong
Post by Ian Lance Taylor
Post by WANG.Jiong
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 {
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
* layout.cc (Layout::add_target_dynamic_tags): If
dynrel_includes_plt but no dyn_rel, emit dynamic reloc tags for
plt_rel.
Loading...