PR gold/13850

* layout.cc (Layout::make_output_section): Correctly mark
	SHT_INIT_ARRAY, et. al., as relro.
This commit is contained in:
Ian Lance Taylor
2012-03-15 16:32:22 +00:00
parent 57651221de
commit 14dc9ef7d1
2 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2012-03-15 Ian Lance Taylor <iant@google.com>
PR gold/13850
* layout.cc (Layout::make_output_section): Correctly mark
SHT_INIT_ARRAY, et. al., as relro.
2012-03-14 Doug Kwan <dougkwan@google.com> 2012-03-14 Doug Kwan <dougkwan@google.com>
* gold/arm.cc (Target_arm::Scan::global): Generate R_ARM_GLOB_DAT * gold/arm.cc (Target_arm::Scan::global): Generate R_ARM_GLOB_DAT

View File

@ -1379,9 +1379,10 @@ Layout::make_output_section(const char* name, elfcpp::Elf_Word type,
bool is_relro_local = false; bool is_relro_local = false;
if (!this->script_options_->saw_sections_clause() if (!this->script_options_->saw_sections_clause()
&& parameters->options().relro() && parameters->options().relro()
&& type == elfcpp::SHT_PROGBITS
&& (flags & elfcpp::SHF_ALLOC) != 0 && (flags & elfcpp::SHF_ALLOC) != 0
&& (flags & elfcpp::SHF_WRITE) != 0) && (flags & elfcpp::SHF_WRITE) != 0)
{
if (type == elfcpp::SHT_PROGBITS)
{ {
if (strcmp(name, ".data.rel.ro") == 0) if (strcmp(name, ".data.rel.ro") == 0)
is_relro = true; is_relro = true;
@ -1390,15 +1391,16 @@ Layout::make_output_section(const char* name, elfcpp::Elf_Word type,
is_relro = true; is_relro = true;
is_relro_local = true; is_relro_local = true;
} }
else if (type == elfcpp::SHT_INIT_ARRAY
|| type == elfcpp::SHT_FINI_ARRAY
|| type == elfcpp::SHT_PREINIT_ARRAY)
is_relro = true;
else if (strcmp(name, ".ctors") == 0 else if (strcmp(name, ".ctors") == 0
|| strcmp(name, ".dtors") == 0 || strcmp(name, ".dtors") == 0
|| strcmp(name, ".jcr") == 0) || strcmp(name, ".jcr") == 0)
is_relro = true; is_relro = true;
} }
else if (type == elfcpp::SHT_INIT_ARRAY
|| type == elfcpp::SHT_FINI_ARRAY
|| type == elfcpp::SHT_PREINIT_ARRAY)
is_relro = true;
}
if (is_relro) if (is_relro)
os->set_is_relro(); os->set_is_relro();