| Index: gold/layout.cc
|
| ===================================================================
|
| --- a/gold/layout.cc
|
| +++ b/gold/layout.cc
|
| @@ -2543,6 +2543,11 @@
|
|
|
| file_header->set_section_info(this->section_headers_, shstrtab_section);
|
|
|
| + // Sets data with values that are only known after sections are finalized.
|
| + // For MIPS it is needed to set flag if there are more then 0x10000 symbols
|
| + // in dynamic symbol table.
|
| + target->fix_sections (this, symtab);
|
| +
|
| // Now we know exactly where everything goes in the output file
|
| // (except for non-allocated sections which require postprocessing).
|
| Output_data::layout_complete();
|
| @@ -2973,12 +2978,32 @@
|
| if (type2 == elfcpp::PT_INTERP)
|
| return false;
|
|
|
| + // This single PT_MIPS_REGINFO segment is required to precede any loadable
|
| + // segment. We simply make it always third.
|
| + // TODO AS: Make this only valid for MIPS !!!
|
| + if (type1 == elfcpp::PT_MIPS_REGINFO)
|
| + {
|
| + gold_assert(type2 != elfcpp::PT_MIPS_REGINFO);
|
| + return true;
|
| + }
|
| + if (type2 == elfcpp::PT_MIPS_REGINFO)
|
| + return false;
|
| +
|
| // We then put PT_LOAD segments before any other segments.
|
| if (type1 == elfcpp::PT_LOAD && type2 != elfcpp::PT_LOAD)
|
| return true;
|
| if (type2 == elfcpp::PT_LOAD && type1 != elfcpp::PT_LOAD)
|
| return false;
|
|
|
| + // MIPS needs PT_NULL segment to be last.
|
| + if (type1 == elfcpp::PT_NULL)
|
| + {
|
| + gold_assert(type2 != elfcpp::PT_NULL);
|
| + return false;
|
| + }
|
| + if (type2 == elfcpp::PT_NULL)
|
| + return true;
|
| +
|
| // We put the PT_TLS segment last except for the PT_GNU_RELRO
|
| // segment, because that is where the dynamic linker expects to find
|
| // it (this is just for efficiency; other positions would also work
|
| @@ -4509,7 +4534,8 @@
|
| && parameters->options().shared())
|
| gold_warning(_("shared library text segment is not shareable"));
|
| }
|
| - if (parameters->options().shared() && this->has_static_tls())
|
| + if ((parameters->options().shared() || parameters->options().pie())
|
| + && this->has_static_tls())
|
| flags |= elfcpp::DF_STATIC_TLS;
|
| if (parameters->options().origin())
|
| flags |= elfcpp::DF_ORIGIN;
|
|
|