diff options
author | Ed Maste <emaste@FreeBSD.org> | 2014-12-22 20:32:23 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2014-12-22 20:32:23 +0000 |
commit | 5eccfb5cf5403e9e564066e0a75d80534b49e91d (patch) | |
tree | 78347950207dea134308b7c9d4843204e80507e0 /elfcopy | |
parent | 5265ace0e440a23fb522c516f4ee20f43eaed2b3 (diff) | |
download | src-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')
-rw-r--r-- | elfcopy/archive.c | 11 | ||||
-rw-r--r-- | elfcopy/main.c | 5 | ||||
-rw-r--r-- | elfcopy/sections.c | 25 | ||||
-rw-r--r-- | elfcopy/segments.c | 12 | ||||
-rw-r--r-- | elfcopy/symbols.c | 5 |
5 files changed, 31 insertions, 27 deletions
diff --git a/elfcopy/archive.c b/elfcopy/archive.c index a4f8017989ba..4735f02296e3 100644 --- a/elfcopy/archive.c +++ b/elfcopy/archive.c @@ -40,7 +40,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: archive.c 2370 2011-12-29 12:48:12Z jkoshy $"); +ELFTC_VCSID("$Id: archive.c 3102 2014-10-29 21:09:01Z jkoshy $"); #define _ARMAG_LEN 8 /* length of ar magic string */ #define _ARHDR_LEN 60 /* length of ar header */ @@ -350,12 +350,11 @@ ac_detect_ar(int ifd) r = -1; if ((a = archive_read_new()) == NULL) return (0); - archive_read_support_compression_none(a); archive_read_support_format_ar(a); if (archive_read_open_fd(a, ifd, 10240) == ARCHIVE_OK) r = archive_read_next_header(a, &entry); archive_read_close(a); - archive_read_finish(a); + archive_read_free(a); return (r == ARCHIVE_OK); } @@ -386,7 +385,6 @@ ac_read_objs(struct elfcopy *ecp, int ifd) err(EXIT_FAILURE, "lseek failed"); if ((a = archive_read_new()) == NULL) errx(EXIT_FAILURE, "%s", archive_error_string(a)); - archive_read_support_compression_none(a); archive_read_support_format_ar(a); AC(archive_read_open_fd(a, ifd, 10240)); for(;;) { @@ -435,7 +433,7 @@ ac_read_objs(struct elfcopy *ecp, int ifd) } } AC(archive_read_close(a)); - ACV(archive_read_finish(a)); + ACV(archive_read_free(a)); } static void @@ -449,7 +447,6 @@ ac_write_objs(struct elfcopy *ecp, int ofd) if ((a = archive_write_new()) == NULL) errx(EXIT_FAILURE, "%s", archive_error_string(a)); archive_write_set_format_ar_svr4(a); - archive_write_set_compression_none(a); AC(archive_write_open_fd(a, ofd)); /* Write the archive symbol table, even if it's empty. */ @@ -491,7 +488,7 @@ ac_write_objs(struct elfcopy *ecp, int ofd) } AC(archive_write_close(a)); - ACV(archive_write_finish(a)); + ACV(archive_write_free(a)); } static void diff --git a/elfcopy/main.c b/elfcopy/main.c index 3689f355fecd..0ba4e6864c86 100644 --- a/elfcopy/main.c +++ b/elfcopy/main.c @@ -40,7 +40,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: main.c 2970 2013-12-01 15:22:12Z kaiwang27 $"); +ELFTC_VCSID("$Id: main.c 3111 2014-12-20 08:33:01Z kaiwang27 $"); enum options { @@ -1109,7 +1109,8 @@ strip_main(struct elfcopy *ecp, int argc, char **argv) if (ecp->strip == 0 && ((ecp->flags & DISCARD_LOCAL) == 0) && - ((ecp->flags & DISCARD_LLABEL) == 0)) + ((ecp->flags & DISCARD_LLABEL) == 0) && + lookup_symop_list(ecp, NULL, SYMOP_STRIP) == NULL) ecp->strip = STRIP_ALL; if (optind == argc) strip_usage(); diff --git a/elfcopy/sections.c b/elfcopy/sections.c index d01659a935ee..c503666c8948 100644 --- a/elfcopy/sections.c +++ b/elfcopy/sections.c @@ -35,7 +35,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: sections.c 2358 2011-12-19 18:22:32Z kaiwang27 $"); +ELFTC_VCSID("$Id: sections.c 3126 2014-12-21 08:03:31Z kaiwang27 $"); static void add_gnu_debuglink(struct elfcopy *ecp); static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc); @@ -372,6 +372,14 @@ create_scn(struct elfcopy *ecp) is_remove_reloc_sec(ecp, ish.sh_info)) continue; + /* + * Section groups should be removed if symbol table will + * be removed. (section group's signature stored in symbol + * table) + */ + if (ish.sh_type == SHT_GROUP && ecp->strip == STRIP_ALL) + continue; + /* Get section flags set by user. */ sec_flags = get_section_flags(ecp, name); @@ -762,8 +770,8 @@ resync_sections(struct elfcopy *ecp) s->off = roundup(off, s->align); } else { if (s->loadable) - warnx("moving loadable section," - "is this intentional?"); + warnx("moving loadable section %s, " + "is this intentional?", s->name); s->off = roundup(off, s->align); } @@ -1139,12 +1147,6 @@ add_to_shstrtab(struct elfcopy *ecp, const char *name) struct section *s; s = ecp->shstrtab; - if (s->buf == NULL) { - insert_to_strtab(s, ""); - insert_to_strtab(s, ".symtab"); - insert_to_strtab(s, ".strtab"); - insert_to_strtab(s, ".shstrtab"); - } insert_to_strtab(s, name); } @@ -1206,6 +1208,11 @@ init_shstrtab(struct elfcopy *ecp) s->loadable = 0; s->type = SHT_STRTAB; s->vma = 0; + + insert_to_strtab(s, ""); + insert_to_strtab(s, ".symtab"); + insert_to_strtab(s, ".strtab"); + insert_to_strtab(s, ".shstrtab"); } void 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; } diff --git a/elfcopy/symbols.c b/elfcopy/symbols.c index f2a722736c83..573a18f25e79 100644 --- a/elfcopy/symbols.c +++ b/elfcopy/symbols.c @@ -34,7 +34,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: symbols.c 2971 2013-12-01 15:22:21Z kaiwang27 $"); +ELFTC_VCSID("$Id: symbols.c 3019 2014-04-17 14:53:40Z jkoshy $"); /* Symbol table buffer structure. */ struct symbuf { @@ -300,7 +300,7 @@ generate_symbols(struct elfcopy *ecp) GElf_Sym sym; Elf_Data* id; Elf_Scn *is; - size_t ishstrndx, namelen, ndx, nsyms, sc, symndx; + size_t ishstrndx, namelen, ndx, sc, symndx; int ec, elferr, i; if (elf_getshstrndx(ecp->ein, &ishstrndx) == 0) @@ -320,7 +320,6 @@ generate_symbols(struct elfcopy *ecp) st_buf->lcap = 64; st_buf->lsz = 1; /* '\0' at start. */ st_buf->gsz = 0; - nsyms = 0; ecp->symtab->sz = 0; ecp->strtab->sz = 0; |