Bug 628618 part 5 - Don't set DT_REL*COUNT if it wasn't already set. r=tglek,a=sdwilsh

This commit is contained in:
Mike Hommey 2011-01-28 09:22:58 +01:00
parent 3a7abc2fb4
commit cc0eedf4c6
3 changed files with 11 additions and 3 deletions

View File

@ -619,15 +619,21 @@ ElfSegment *ElfSegment::splitBefore(ElfSection *section)
return segment;
}
ElfSection *ElfDynamic_Section::getSectionForType(unsigned int tag)
ElfValue *ElfDynamic_Section::getValueForType(unsigned int tag)
{
for (unsigned int i = 0; i < shdr.sh_size / shdr.sh_entsize; i++)
if (dyns[i].tag == tag)
return dyns[i].value->getSection();
return dyns[i].value;
return NULL;
}
ElfSection *ElfDynamic_Section::getSectionForType(unsigned int tag)
{
ElfValue *value = getValueForType(tag);
return value ? value->getSection() : NULL;
}
void ElfDynamic_Section::setValueForType(unsigned int tag, ElfValue *val)
{
unsigned int i;

View File

@ -355,7 +355,8 @@ int do_relocation_section(Elf *elf, unsigned int rel_type)
ElfLocation *init = new ElfLocation(relhackcode, 0);
dyn->setValueForType(DT_INIT, init);
// TODO: adjust the value according to the remaining number of relative relocations
dyn->setValueForType(Rel_Type::d_tag_count, new ElfPlainValue(0));
if (dyn->getValueForType(Rel_Type::d_tag_count))
dyn->setValueForType(Rel_Type::d_tag_count, new ElfPlainValue(0));
return 0;
}

View File

@ -452,6 +452,7 @@ public:
void serialize(std::ofstream &file, char ei_class, char ei_data);
ElfValue *getValueForType(unsigned int tag);
ElfSection *getSectionForType(unsigned int tag);
void setValueForType(unsigned int tag, ElfValue *val);
private: