projects
/
centaur.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f54dc5b
)
Fix stupid copy
copy-stupid-rebased
author
norly
<ny-git@enpas.org>
Fri, 1 Feb 2013 15:50:37 +0000
(15:50 +0000)
committer
norly
<ny-git@enpas.org>
Mon, 11 Feb 2013 01:32:32 +0000
(
01:32
+0000)
src/copy/section.c
patch
|
blob
|
history
src/copy/segments.c
patch
|
blob
|
history
diff --git
a/src/copy/section.c
b/src/copy/section.c
index e096b2b7140999c5185a034e9413fcacefe2ed3d..6fd08e29ad1f5f654d2e974713f199561eb2857a 100644
(file)
--- a/
src/copy/section.c
+++ b/
src/copy/section.c
@@
-31,14
+31,13
@@
void elfu_copySection(Elf *eo, Elf_Scn *scn)
shdrOut.sh_name = shdr.sh_name;
shdrOut.sh_type = shdr.sh_type;
shdrOut.sh_flags = shdr.sh_flags;
shdrOut.sh_name = shdr.sh_name;
shdrOut.sh_type = shdr.sh_type;
shdrOut.sh_flags = shdr.sh_flags;
- /* sh_addr */
shdrOut.sh_addr = shdr.sh_addr;
/* sh_offset */
/* sh_size */
shdrOut.sh_link = shdr.sh_link;
shdrOut.sh_info = shdr.sh_info;
shdrOut.sh_addralign = shdr.sh_addralign;
shdrOut.sh_addr = shdr.sh_addr;
/* sh_offset */
/* sh_size */
shdrOut.sh_link = shdr.sh_link;
shdrOut.sh_info = shdr.sh_info;
shdrOut.sh_addralign = shdr.sh_addralign;
-
//
shdrOut.sh_entsize = shdr.sh_entsize;
+ shdrOut.sh_entsize = shdr.sh_entsize;
if (!gelf_update_shdr(scnOut, &shdrOut)) {
fprintf(stderr, "gelf_update_shdr() failed: %s\n", elf_errmsg(-1));
if (!gelf_update_shdr(scnOut, &shdrOut)) {
fprintf(stderr, "gelf_update_shdr() failed: %s\n", elf_errmsg(-1));
diff --git
a/src/copy/segments.c
b/src/copy/segments.c
index 0928de6eac996539c3c7823392080d8e7fc071b6..0f320c178fceb0f3760717fdb6941471176209f0 100644
(file)
--- 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 */
}
if (phdr.p_type == PT_PHDR) {
/* Skip PHDR entries and fix them up later */
}
- else if (phdr.p_
file
sz == 0) {
+ else if (phdr.p_
mem
sz == 0) {
phdrOut.p_filesz = 0;
phdrOut.p_filesz = 0;
+ phdrOut.p_memsz = 0;
} else {
/* Try to guess the end of the segment */
Elf_Scn *scn, *scnOut;
} 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));
}
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)) {
}
if (!gelf_update_phdr (eo, i, &phdrOut)) {