Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/binutils/usr.sbin/dbsym copy the CTF section t...



details:   https://anonhg.NetBSD.org/src/rev/9515cfbc167a
branches:  trunk
changeset: 825253:9515cfbc167a
user:      chs <chs%NetBSD.org@localhost>
date:      Thu Jul 06 02:34:00 2017 +0000

description:
copy the CTF section too, if there is one.

diffstat:

 external/gpl3/binutils/usr.sbin/dbsym/dbsym.c |  27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r e7d32d6be69c -r 9515cfbc167a external/gpl3/binutils/usr.sbin/dbsym/dbsym.c
--- a/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c     Thu Jul 06 00:35:28 2017 +0000
+++ b/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c     Thu Jul 06 02:34:00 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $ */
+/* $NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $ */
 
 /*
  * Copyright (c) 2001 Simon Burge (for Wasabi Systems)
@@ -39,7 +39,7 @@
 __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\
   Copyright 2001 Simon Burge.\
   All rights reserved.");
-__RCSID("$NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $");
+__RCSID("$NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -362,8 +362,9 @@
        Elf32_External_Shdr *s32hdr = NULL;
        Elf64_External_Shdr *s64hdr = NULL;
        void *shdr;
+       char *shstrtab = NULL;
        u_int32_t osymtabsize, sh_offset;
-       int elftype, e_shnum, i, sh_size;
+       int elftype, e_shnum, i, sh_size, rv = 1, shstridx;
        off_t e_shoff;
 
        if (lseek(fd, 0, SEEK_SET) < 0)
@@ -422,8 +423,19 @@
        if (read(fd, shdr, sh_size) != sh_size)
                goto out;
 
+       shstridx = (ISELF64
+          ? bfd_get_16(abfd, e64_hdr.e_shstrndx)
+          : bfd_get_16(abfd, e32_hdr.e_shstrndx));
+       shstrtab = malloc(shstridx);
+       if (shstrtab == NULL)
+               goto out;
+       if (pread(fd, shstrtab, SH_SIZE(shstridx), SH_OFFSET(shstridx)) != 
+           SH_SIZE(shstridx))
+               goto out;
+
        for (i = 0; i < e_shnum; i++) {
-               if (SH_TYPE(i) == SHT_SYMTAB || SH_TYPE(i) == SHT_STRTAB) {
+               if (SH_TYPE(i) == SHT_SYMTAB || SH_TYPE(i) == SHT_STRTAB ||
+                   !strcmp(shstrtab + SH_NAME(i), ".SUNW_ctf")) {
                        osymtabsize = *symtabsize;
                        *symtabsize += roundup(SH_SIZE(i), ISELF64 ? 8 : 4);
                        if ((*symtab = realloc(*symtab, *symtabsize)) == NULL)
@@ -467,10 +479,11 @@
                bfd_put_16(abfd, 0, e32_hdr.e_phnum);
        }
        memcpy(*symtab, &ehdr, sizeof(ehdr));
+       rv = 0;
 
-       free(shdr);
-       return (0);
 out:
+       if (shstrtab != NULL)
+               free(shstrtab);
        free(shdr);
-       return (1);
+       return (rv);
 }



Home | Main Index | Thread Index | Old Index