Chromium Code Reviews| Index: gold/layout.cc |
| =================================================================== |
| --- a/gold/layout.cc |
| +++ b/gold/layout.cc |
| @@ -2543,6 +2543,8 @@ |
| file_header->set_section_info(this->section_headers_, shstrtab_section); |
| + target->fix_sections(this, symtab); |
|
robertm
2012/04/27 19:46:15
add a comment explaining what this does
Aleksandar Simeonov
2012/05/08 15:21:42
Sets data with values that are only known after se
robertm
2012/05/11 21:50:50
The description you give here is much better than
|
| + |
| // 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 +2975,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 +4531,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; |