summaryrefslogtreecommitdiff
path: root/src/copy/segments.c
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-02-01 15:50:37 +0000
committernorly <ny-git@enpas.org>2013-02-11 01:32:32 +0000
commit630aa5494c36a0a13bd7a08397d0d29468854cb9 (patch)
tree994f5d8de117cd31571759b45fee5e80f8ffe6e3 /src/copy/segments.c
parentf54dc5b5697207093a70416a665eddf8c0970a0a (diff)
Fix stupid copycopy-stupid-rebased
Diffstat (limited to 'src/copy/segments.c')
-rw-r--r--src/copy/segments.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/copy/segments.c b/src/copy/segments.c
index 0928de6..0f320c1 100644
--- a/src/copy/segments.c
+++ b/src/copy/segments.c
@@ -114,8 +114,9 @@ void elfu_copySegments2(Elf *eo, Elf *ei)
if (phdr.p_type == PT_PHDR) {
/* Skip PHDR entries and fix them up later */
}
- else if (phdr.p_filesz == 0) {
+ else if (phdr.p_memsz == 0) {
phdrOut.p_filesz = 0;
+ phdrOut.p_memsz = 0;
} else {
/* Try to guess the end of the segment */
Elf_Scn *scn, *scnOut;
@@ -144,17 +145,12 @@ void elfu_copySegments2(Elf *eo, Elf *ei)
fprintf(stderr, "gelf_getshdr() failed: %s\n", elf_errmsg(-1));
}
- phdrOut.p_filesz = shdrOut.sh_offset - phdrOut.p_offset + shdrOut.sh_size;
- }
+ phdrOut.p_filesz = shdrOut.sh_offset - phdrOut.p_offset;
+ if (shdrOut.sh_type != SHT_NOBITS) {
+ phdrOut.p_filesz += shdrOut.sh_size;
+ }
- if (phdr.p_type == PT_PHDR) {
- /* Skip PHDR entries and fix them up later */
- }
- else if (phdr.p_memsz == 0) {
- phdrOut.p_memsz = 0;
- } else {
- // TODO: Calculate memory size (depends on .bss, etc.)
- phdrOut.p_memsz = phdrOut.p_filesz; // FIXME
+ phdrOut.p_memsz = shdrOut.sh_offset - phdrOut.p_offset + shdrOut.sh_size;
}
if (!gelf_update_phdr (eo, i, &phdrOut)) {