Skip to content

Commit

Permalink
[nanoMIPS] Add eh_frame start and end symbols
Browse files Browse the repository at this point in the history
eh_frame start and end symbols need to be defined if there is an
eh_frame section. Unwinding depends on these symbols.
  • Loading branch information
AndrijaSyrmia committed Oct 24, 2024
1 parent a50a0b2 commit 9d9037d
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions gold/nanomips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,11 @@ class Target_nanomips : public Sized_target<size, big_endian>
sections.insert(".nanoMIPS.abiflags");
}

// Defines eh_frame and eh_frame_hdr start and end symbols if these
// sections are defined.
void
do_define_standard_symbols(Symbol_table*, Layout*);

private:
// The class which scans relocations.
class Scan
Expand Down Expand Up @@ -2342,6 +2347,12 @@ class Target_nanomips : public Sized_target<size, big_endian>
void
set_gp(Layout*, Symbol_table*);

// Define start and end symbols, used to define eh_frame start and
// end
void
define_start_end_symbols(const char* start, const char* end,
Symbol_table*, Output_section*);

// Information about this specific target which we pass to the
// general Target structure.
static const Target::Target_info nanomips_info;
Expand Down Expand Up @@ -6643,6 +6654,69 @@ Target_nanomips<size, big_endian>::do_finalize_sections(
this->rel_dyn_, true, false);
}

template <int size, bool big_endian>
void
Target_nanomips<size, big_endian>::do_define_standard_symbols(
Symbol_table* symtab,
Layout* layout)
{
Output_section* eh_frame_section =
layout->find_output_section(".eh_frame");

if (eh_frame_section != NULL)
{
this->define_start_end_symbols("__eh_frame_start",
"__eh_frame_end",
symtab,
eh_frame_section);
Output_section* eh_frame_hdr_section =
layout->find_output_section(".eh_frame_hdr");

if (eh_frame_hdr_section != NULL)
this->define_start_end_symbols("__eh_frame_hdr_start",
"__eh_frame_hdr_end",
symtab,
eh_frame_hdr_section);
}
}

template <int size, bool big_endian>
void
Target_nanomips<size, big_endian>::define_start_end_symbols(
const char* start,
const char* end,
Symbol_table* symtab,
Output_section* out_sec)
{
gold_assert(out_sec != NULL);

symtab->define_in_output_data(start,
NULL, // version
Symbol_table::PREDEFINED,
out_sec,
0, // value
0, // symsize
elfcpp::STT_NOTYPE,
elfcpp::STB_GLOBAL,
elfcpp::STV_HIDDEN,
0, // nonvis
false, // offset_is_from_end
true); // only_if_ref

symtab->define_in_output_data(end,
NULL, // version
Symbol_table::PREDEFINED,
out_sec,
0, // value
0, // symsize
elfcpp::STT_NOTYPE,
elfcpp::STB_GLOBAL,
elfcpp::STV_HIDDEN,
0, // nonvis
true, // offset_is_from_end
true); // only_if_ref
}

// Relocate section data.

template<int size, bool big_endian>
Expand Down

0 comments on commit 9d9037d

Please sign in to comment.