This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [gold] arm: fix exidx in relocatable builds
- From: Yury Usishchev <y dot usishchev at samsung dot com>
- To: binutils at sourceware dot org
- Cc: Doug Kwan <dougkwan at google dot com>, Ian Lance Taylor <ian at airs dot com>
- Date: Thu, 28 Jan 2016 17:50:26 +0300
- Subject: Re: [gold] arm: fix exidx in relocatable builds
- Authentication-results: sourceware.org; auth=none
- References: <87powl4v9y dot fsf at samsung dot com>
Forgot to attach the file=)
commit 84d5b00ce910369002227cd7e380660b39da8ba9
Author: Yury Usishchev <y.usishchev@samsung.com>
Date: Mon Jan 25 17:47:01 2016 +0300
add relaxation to relocatable builds, only fix exidx there
diff --git a/gold/arm.cc b/gold/arm.cc
index 9716195..4984ff8 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -2520,7 +2520,8 @@ class Target_arm : public Sized_target<32, big_endian>
// not doing relocatable linking.
bool
do_may_relax() const
- { return !parameters->options().relocatable(); }
+ { return 1; }
+ //{ return !parameters->options().relocatable(); }
bool
do_relax(int, const Input_objects*, Symbol_table*, Layout*, const Task*);
@@ -5634,6 +5635,7 @@ Arm_exidx_fixup::process_exidx_section(
bool prev_delete_entry = false;
gold_assert(this->section_offset_map_ == NULL);
+ if(!parameters->options().relocatable())
for (section_size_type i = 0; i < section_size; i += 8)
{
typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype;
@@ -5665,6 +5667,7 @@ Arm_exidx_fixup::process_exidx_section(
// If section offset map is not NULL, make an entry for the end of
// section.
+ if(!parameters->options().relocatable())
if (this->section_offset_map_ != NULL)
update_offset_map(section_size - 1, deleted_bytes, prev_delete_entry);
@@ -6083,9 +6086,11 @@ Arm_output_section<big_endian>::fix_exidx_coverage(
}
// Insert an EXIDX_CANTUNWIND entry at the end of output if necessary.
- exidx_fixup.add_exidx_cantunwind_as_needed();
+ if(parameters->options().relocatable())
+ exidx_fixup.add_exidx_cantunwind_as_needed();
// Remove any known EXIDX input sections that are not processed.
+ if(!parameters->options().relocatable())
for (Input_section_list::const_iterator p = input_sections.begin();
p != input_sections.end();
++p)
@@ -12203,11 +12208,42 @@ Target_arm<big_endian>::do_relax(
const Task* task)
{
// No need to generate stubs if this is a relocatable link.
- gold_assert(!parameters->options().relocatable());
+ bool done_exidx_fixup = false;
+ if (pass == 1)
+ {
+ Arm_output_section<big_endian>* exidx_output_section = NULL;
+ for (Layout::Section_list::const_iterator p =
+ layout->section_list().begin();
+ p != layout->section_list().end();
+ ++p)
+ if ((*p)->type() == elfcpp::SHT_ARM_EXIDX)
+ {
+ if (exidx_output_section == NULL)
+ exidx_output_section =
+ Arm_output_section<big_endian>::as_arm_output_section(*p);
+ else
+ // We cannot handle this now.
+ gold_error(_("multiple SHT_ARM_EXIDX sections %s and %s in a "
+ "non-relocatable link"),
+ exidx_output_section->name(),
+ (*p)->name());
+ }
+
+ if (exidx_output_section != NULL)
+ {
+ this->fix_exidx_coverage(layout, input_objects, exidx_output_section,
+ symtab, task);
+ done_exidx_fixup = true;
+ }
+ }
+
+ // if not relocatable - we dont need second run
+ if(parameters->options().relocatable())
+ return done_exidx_fixup;
+ //gold_assert(!parameters->options().relocatable());
// If this is the first pass, we need to group input sections into
// stub groups.
- bool done_exidx_fixup = false;
typedef typename Stub_table_list::iterator Stub_table_iterator;
if (pass == 1)
{
@@ -12252,30 +12288,6 @@ Target_arm<big_endian>::do_relax(
group_sections(layout, stub_group_size, stubs_always_after_branch, task);
// Also fix .ARM.exidx section coverage.
- Arm_output_section<big_endian>* exidx_output_section = NULL;
- for (Layout::Section_list::const_iterator p =
- layout->section_list().begin();
- p != layout->section_list().end();
- ++p)
- if ((*p)->type() == elfcpp::SHT_ARM_EXIDX)
- {
- if (exidx_output_section == NULL)
- exidx_output_section =
- Arm_output_section<big_endian>::as_arm_output_section(*p);
- else
- // We cannot handle this now.
- gold_error(_("multiple SHT_ARM_EXIDX sections %s and %s in a "
- "non-relocatable link"),
- exidx_output_section->name(),
- (*p)->name());
- }
-
- if (exidx_output_section != NULL)
- {
- this->fix_exidx_coverage(layout, input_objects, exidx_output_section,
- symtab, task);
- done_exidx_fixup = true;
- }
}
else
{
BR,
Yury Usishchev
Yury Usishchev <y.usishchev@samsung.com> writes:
> Hello all!
>
> I want to fix PR19524 (https://sourceware.org/bugzilla/show_bug.cgi?id=19524).
> In relocatable builds linker does not fix unwind info, leaving some gaps, this can cause problems in unwinder including
> segmentation faults.
> The same issue was fixed for BFD linker in PR17323 (https://sourceware.org/bugzilla/show_bug.cgi?id=17323).
>
> To fix the problem I suppose I need to add part of relaxation where exidx fixup is done to relocatable builds and
> generate correct relocation for new unwind info.
>
> For now I managed to generate required 'cantunwind' but not the relocation, and it is done in very hacky way (see
> attached).
>
> Could some Gold hacker help me with advice on creating the fix? Here are the main issues I would like to discuss:
> 1) Where exidx fix should be called from in relocatable builds?(how wrong is it to run relaxation in such builds)
> 2) Is it possible to create a relocation in Gold? If so, how can I achieve this?
> 3) Where should this relocation be created and placed?
>
> Any help will be appreciated.
>
> BR,
> Yury Usishchev