Source-Changes-HG archive

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

[src/trunk]: src/external/cddl/osnet/dist/tools/ctf/cvt Don't bail out if the...



details:   https://anonhg.NetBSD.org/src/rev/c460483ecf81
branches:  trunk
changeset: 372777:c460483ecf81
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 25 20:23:42 2022 +0000

description:
Don't bail out if the input file does not have a symbol table. This happens
with crtn.o which used to have an empty symbol table with binutils 2.34,
with binutils 2.39 has no symbol table.

diffstat:

 external/cddl/osnet/dist/tools/ctf/cvt/output.c |  22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diffs (47 lines):

diff -r b8cc76e1ae27 -r c460483ecf81 external/cddl/osnet/dist/tools/ctf/cvt/output.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/output.c   Sun Dec 25 20:06:00 2022 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/output.c   Sun Dec 25 20:23:42 2022 +0000
@@ -353,15 +353,17 @@
        match.iim_file = NULL;
 
        if ((stidx = findelfsecidx(elf, file,
-           dynsym ? ".dynsym" : ".symtab")) < 0)
-               terminate("%s: Can't open symbol table\n", file);
-       scn = elf_getscn(elf, stidx);
-       data = elf_getdata(scn, NULL);
-       gelf_getshdr(scn, &shdr);
-       nent = shdr.sh_size / shdr.sh_entsize;
+           dynsym ? ".dynsym" : ".symtab")) < 0) {
+               nent = 0;
+       } else {
+               scn = elf_getscn(elf, stidx);
+               data = elf_getdata(scn, NULL);
+               gelf_getshdr(scn, &shdr);
+               nent = shdr.sh_size / shdr.sh_entsize;
 
-       scn = elf_getscn(elf, shdr.sh_link);
-       strdata = elf_getdata(scn, NULL);
+               scn = elf_getscn(elf, shdr.sh_link);
+               strdata = elf_getdata(scn, NULL);
+       }
 
        iiburst = iiburst_new(td, nent);
 
@@ -665,8 +667,7 @@
        }
 
        if (symtab_idx == -1) {
-               terminate("%s: Cannot find %s section\n", srcname,
-                   dynsym ? "SHT_DYNSYM" : "SHT_SYMTAB");
+               goto out;
        }
 
        /* Add the ctf section */
@@ -709,6 +710,7 @@
        /* commit to disk */
        dehdr.e_shstrndx = secxlate[sehdr.e_shstrndx];
        gelf_update_ehdr(dst, &dehdr);
+out:
        if (elf_update(dst, ELF_C_WRITE) < 0)
                elfterminate(dstname, "Cannot finalize temp file");
 



Home | Main Index | Thread Index | Old Index