|
@@ -563,6 +563,7 @@ int elf_write(struct elf *elf)
|
|
struct section *sec;
|
|
struct section *sec;
|
|
Elf_Scn *s;
|
|
Elf_Scn *s;
|
|
|
|
|
|
|
|
+ /* Update section headers for changed sections: */
|
|
list_for_each_entry(sec, &elf->sections, list) {
|
|
list_for_each_entry(sec, &elf->sections, list) {
|
|
if (sec->changed) {
|
|
if (sec->changed) {
|
|
s = elf_getscn(elf->elf, sec->idx);
|
|
s = elf_getscn(elf->elf, sec->idx);
|
|
@@ -570,13 +571,17 @@ int elf_write(struct elf *elf)
|
|
WARN_ELF("elf_getscn");
|
|
WARN_ELF("elf_getscn");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- if (!gelf_update_shdr (s, &sec->sh)) {
|
|
|
|
|
|
+ if (!gelf_update_shdr(s, &sec->sh)) {
|
|
WARN_ELF("gelf_update_shdr");
|
|
WARN_ELF("gelf_update_shdr");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /* Make sure the new section header entries get updated properly. */
|
|
|
|
+ elf_flagelf(elf->elf, ELF_C_SET, ELF_F_DIRTY);
|
|
|
|
+
|
|
|
|
+ /* Write all changes to the file. */
|
|
if (elf_update(elf->elf, ELF_C_WRITE) < 0) {
|
|
if (elf_update(elf->elf, ELF_C_WRITE) < 0) {
|
|
WARN_ELF("elf_update");
|
|
WARN_ELF("elf_update");
|
|
return -1;
|
|
return -1;
|