aboutsummaryrefslogtreecommitdiff
path: root/elfcopy/segments.c
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2014-12-22 20:32:23 +0000
committerEd Maste <emaste@FreeBSD.org>2014-12-22 20:32:23 +0000
commit5eccfb5cf5403e9e564066e0a75d80534b49e91d (patch)
tree78347950207dea134308b7c9d4843204e80507e0 /elfcopy/segments.c
parent5265ace0e440a23fb522c516f4ee20f43eaed2b3 (diff)
downloadsrc-5eccfb5cf5403e9e564066e0a75d80534b49e91d.tar.gz
src-5eccfb5cf5403e9e564066e0a75d80534b49e91d.zip
Import elftoolchain rev 3130vendor/elftoolchain/elftoolchain-r3130
From svn.code.sf.net/p/elftoolchain/code/trunk
Notes
Notes: svn path=/vendor/elftoolchain/dist/; revision=276077 svn path=/vendor/elftoolchain/elftoolchain-r3130/; revision=276078; tag=vendor/elftoolchain/elftoolchain-r3130
Diffstat (limited to 'elfcopy/segments.c')
-rw-r--r--elfcopy/segments.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/elfcopy/segments.c b/elfcopy/segments.c
index c54cbfcbb07a..e48ad127bfd0 100644
--- a/elfcopy/segments.c
+++ b/elfcopy/segments.c
@@ -34,7 +34,7 @@
#include "elfcopy.h"
-ELFTC_VCSID("$Id: segments.c 2542 2012-08-12 16:14:15Z kaiwang27 $");
+ELFTC_VCSID("$Id: segments.c 3113 2014-12-20 08:33:29Z kaiwang27 $");
static void insert_to_inseg_list(struct segment *seg, struct section *sec);
@@ -72,13 +72,15 @@ add_to_inseg_list(struct elfcopy *ecp, struct section *s)
*/
loadable = 0;
STAILQ_FOREACH(seg, &ecp->v_seg, seg_list) {
- if (s->off < seg->off)
+ if (s->off < seg->off || (s->vma < seg->addr && !s->pseudo))
continue;
if (s->off + s->sz > seg->off + seg->fsz &&
s->type != SHT_NOBITS)
continue;
if (s->off + s->sz > seg->off + seg->msz)
continue;
+ if (s->vma + s->sz > seg->addr + seg->msz)
+ continue;
insert_to_inseg_list(seg, s);
if (seg->type == PT_LOAD)
@@ -96,7 +98,7 @@ adjust_addr(struct elfcopy *ecp)
struct section *s, *s0;
struct segment *seg;
struct sec_action *sac;
- uint64_t dl, lma, old_vma, start, end;
+ uint64_t dl, lma, start, end;
int found, i;
/*
@@ -113,8 +115,6 @@ adjust_addr(struct elfcopy *ecp)
s->lma += ecp->change_addr;
if (!s->pseudo) {
- old_vma = s->vma;
-
/* Apply global VMA adjustment. */
if (ecp->change_addr != 0)
s->vma += ecp->change_addr;
@@ -438,7 +438,7 @@ copy_phdr(struct elfcopy *ecp)
seg->fsz = seg->msz = 0;
for (i = 0; i < seg->nsec; i++) {
s = seg->v_sec[i];
- seg->msz = s->off + s->sz - seg->off;
+ seg->msz = s->vma + s->sz - seg->addr;
if (s->type != SHT_NOBITS)
seg->fsz = seg->msz;
}