diff --git a/addr2line/addr2line.c b/addr2line/addr2line.c index 55f450d372c4..9c3a764fcd0d 100644 --- a/addr2line/addr2line.c +++ b/addr2line/addr2line.c @@ -40,7 +40,7 @@ #include "uthash.h" #include "_elftc.h" -ELFTC_VCSID("$Id: addr2line.c 3446 2016-05-03 01:31:17Z emaste $"); +ELFTC_VCSID("$Id: addr2line.c 3499 2016-11-25 16:06:29Z emaste $"); struct Func { char *name; @@ -720,11 +720,11 @@ main(int argc, char **argv) if (argc > 0) for (i = 0; i < argc; i++) translate(dbg, e, argv[i]); - else - while (fgets(line, sizeof(line), stdin) != NULL) { + else { + setvbuf(stdout, NULL, _IOLBF, 0); + while (fgets(line, sizeof(line), stdin) != NULL) translate(dbg, e, line); - fflush(stdout); - } + } dwarf_finish(dbg, &de); diff --git a/ar/os.FreeBSD.mk b/ar/os.FreeBSD.mk new file mode 100644 index 000000000000..c29af70518a9 --- /dev/null +++ b/ar/os.FreeBSD.mk @@ -0,0 +1,2 @@ +DPADD+= ${LIBBZ2} +LDADD+= -lbz2 diff --git a/common/elfdefinitions.h b/common/elfdefinitions.h index 7460bb68443f..810da8d4951a 100644 --- a/common/elfdefinitions.h +++ b/common/elfdefinitions.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elfdefinitions.h 3485 2016-08-18 13:38:52Z emaste $ + * $Id: elfdefinitions.h 3515 2017-01-24 22:04:22Z emaste $ */ /* @@ -153,6 +153,8 @@ _ELF_DEFINE_DT(DT_SUNW_FILTER, 0x6000000FUL, \ "offset of string naming standard filtees") \ _ELF_DEFINE_DT(DT_SUNW_CAP, 0x60000010UL, \ "address of hardware capabilities section") \ +_ELF_DEFINE_DT(DT_SUNW_ASLR, 0x60000023UL, \ + "Address Space Layout Randomization flag") \ _ELF_DEFINE_DT(DT_HIOS, 0x6FFFF000UL, \ "end of OS-specific types") \ _ELF_DEFINE_DT(DT_VALRNGLO, 0x6FFFFD00UL, \ @@ -919,6 +921,12 @@ _ELF_DEFINE_PT(PT_GNU_STACK, 0x6474E551UL, \ "Stack flags") \ _ELF_DEFINE_PT(PT_GNU_RELRO, 0x6474E552UL, \ "Segment becomes read-only after relocation") \ +_ELF_DEFINE_PT(PT_OPENBSD_RANDOMIZE,0x65A3DBE6UL, \ + "Segment filled with random data") \ +_ELF_DEFINE_PT(PT_OPENBSD_WXNEEDED, 0x65A3DBE7UL, \ + "Program violates W^X") \ +_ELF_DEFINE_PT(PT_OPENBSD_BOOTDATA, 0x65A41BE6UL, \ + "Boot data") \ _ELF_DEFINE_PT(PT_SUNWBSS, 0x6FFFFFFAUL, \ "A Solaris .SUNW_bss section") \ _ELF_DEFINE_PT(PT_SUNWSTACK, 0x6FFFFFFBUL, \ diff --git a/cxxfilt/cxxfilt.c b/cxxfilt/cxxfilt.c index c6d737a05267..9a051fb4151c 100644 --- a/cxxfilt/cxxfilt.c +++ b/cxxfilt/cxxfilt.c @@ -35,7 +35,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: cxxfilt.c 3454 2016-05-07 17:11:05Z kaiwang27 $"); +ELFTC_VCSID("$Id: cxxfilt.c 3499 2016-11-25 16:06:29Z emaste $"); #define STRBUFSZ 8192 @@ -175,6 +175,7 @@ main(int argc, char **argv) } else { p = 0; for (;;) { + setvbuf(stdout, NULL, _IOLBF, 0); c = fgetc(stdin); if (c == EOF || !(isalnum(c) || strchr(".$_", c))) { if (p > 0) { diff --git a/elfcopy/main.c b/elfcopy/main.c index ebc0c92a1c01..cc16dcab0cd6 100644 --- a/elfcopy/main.c +++ b/elfcopy/main.c @@ -39,7 +39,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: main.c 3446 2016-05-03 01:31:17Z emaste $"); +ELFTC_VCSID("$Id: main.c 3520 2017-04-17 01:47:52Z kaiwang27 $"); enum options { @@ -285,6 +285,7 @@ create_elf(struct elfcopy *ecp) size_t ishnum; ecp->flags |= SYMTAB_INTACT; + ecp->flags &= ~SYMTAB_EXIST; /* Create EHDR. */ if (gelf_getehdr(ecp->ein, &ieh) == NULL) @@ -499,6 +500,10 @@ free_elf(struct elfcopy *ecp) } } + ecp->symtab = NULL; + ecp->strtab = NULL; + ecp->shstrtab = NULL; + if (ecp->secndx != NULL) { free(ecp->secndx); ecp->secndx = NULL; diff --git a/elfcopy/os.FreeBSD.mk b/elfcopy/os.FreeBSD.mk new file mode 100644 index 000000000000..389cb59e8c7b --- /dev/null +++ b/elfcopy/os.FreeBSD.mk @@ -0,0 +1,4 @@ +.if !defined(LIBELF_AR) +DPADD+= ${LIBBZ2} +LDADD+= -lbz2 +.endif diff --git a/elfcopy/pe.c b/elfcopy/pe.c index 8deb80918553..f7fba1ae40d6 100644 --- a/elfcopy/pe.c +++ b/elfcopy/pe.c @@ -34,7 +34,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: pe.c 3490 2016-08-31 00:12:22Z emaste $"); +ELFTC_VCSID("$Id: pe.c 3508 2016-12-27 06:19:39Z kaiwang27 $"); /* Convert ELF object to Portable Executable (PE). */ void @@ -70,7 +70,7 @@ create_pe(struct elfcopy *ecp, int ifd, int ofd) errx(EXIT_FAILURE, "gelf_getehdr() failed: %s", elf_errmsg(-1)); - if (elf_getshstrndx(ecp->ein, &indx) == 0) + if (elf_getshstrndx(e, &indx) == 0) errx(EXIT_FAILURE, "elf_getshstrndx() failed: %s", elf_errmsg(-1)); @@ -124,7 +124,7 @@ create_pe(struct elfcopy *ecp, int ifd, int ofd) (void) elf_errno(); continue; } - if ((name = elf_strptr(ecp->ein, indx, sh.sh_name)) == + if ((name = elf_strptr(e, indx, sh.sh_name)) == NULL) { warnx("elf_strptr() failed: %s", elf_errmsg(-1)); (void) elf_errno(); @@ -210,12 +210,14 @@ create_pe(struct elfcopy *ecp, int ifd, int ofd) } pb->pb_align = 1; pb->pb_off = 0; - pb->pb_size = roundup(sh.sh_size, poh.oh_filealign); - if ((pb->pb_buf = calloc(1, pb->pb_size)) == NULL) { - warn("calloc failed"); - continue; + if (sh.sh_type != SHT_NOBITS) { + pb->pb_size = roundup(sh.sh_size, poh.oh_filealign); + if ((pb->pb_buf = calloc(1, pb->pb_size)) == NULL) { + warn("calloc failed"); + continue; + } + memcpy(pb->pb_buf, d->d_buf, sh.sh_size); } - memcpy(pb->pb_buf, d->d_buf, sh.sh_size); } elferr = elf_errno(); if (elferr != 0) diff --git a/elfcopy/symbols.c b/elfcopy/symbols.c index d072da8a1aba..a10b30e1a357 100644 --- a/elfcopy/symbols.c +++ b/elfcopy/symbols.c @@ -34,7 +34,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: symbols.c 3446 2016-05-03 01:31:17Z emaste $"); +ELFTC_VCSID("$Id: symbols.c 3520 2017-04-17 01:47:52Z kaiwang27 $"); /* Symbol table buffer structure. */ struct symbuf { @@ -670,6 +670,8 @@ create_symtab(struct elfcopy *ecp) sy = ecp->symtab; st = ecp->strtab; + assert(sy != NULL && st != NULL); + /* * Set section index map for .symtab and .strtab. We need to set * these map because otherwise symbols which refer to .symtab and diff --git a/elfdump/elfdump.c b/elfdump/elfdump.c index 2ce9469f8367..2e8620c2d492 100644 --- a/elfdump/elfdump.c +++ b/elfdump/elfdump.c @@ -50,7 +50,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: elfdump.c 3482 2016-08-02 18:47:00Z emaste $"); +ELFTC_VCSID("$Id: elfdump.c 3497 2016-10-17 20:57:22Z emaste $"); #if defined(ELFTC_NEED_ELF_NOTE_DEFINITION) #include "native-elf-format.h" @@ -223,9 +223,9 @@ d_tags(uint64_t tag) case 0x6ffffff0: return "DT_GNU_VERSYM"; /* 0x70000000 - 0x7fffffff processor-specific semantics */ case 0x70000000: return "DT_IA_64_PLT_RESERVE"; - case 0x7ffffffd: return "DT_SUNW_AUXILIARY"; - case 0x7ffffffe: return "DT_SUNW_USED"; - case 0x7fffffff: return "DT_SUNW_FILTER"; + case DT_AUXILIARY: return "DT_AUXILIARY"; + case DT_USED: return "DT_USED"; + case DT_FILTER: return "DT_FILTER"; } snprintf(unknown_buf, sizeof(unknown_buf), diff --git a/libdwarf/dwarf.h b/libdwarf/dwarf.h index c79da96dbb47..632256886981 100644 --- a/libdwarf/dwarf.h +++ b/libdwarf/dwarf.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: dwarf.h 3052 2014-05-26 20:36:24Z kaiwang27 $ + * $Id: dwarf.h 3494 2016-09-20 17:16:13Z emaste $ */ #ifndef _DWARF_H_ @@ -208,6 +208,25 @@ #define DW_AT_lo_user 0x2000 #define DW_AT_hi_user 0x3fff +/* SGI/MIPS extensions. */ +#define DW_AT_MIPS_fde 0x2001 +#define DW_AT_MIPS_loop_begin 0x2002 +#define DW_AT_MIPS_tail_loop_begin 0x2003 +#define DW_AT_MIPS_epilog_begin 0x2004 +#define DW_AT_MIPS_loop_unroll_factor 0x2005 +#define DW_AT_MIPS_software_pipeline_depth 0x2006 +#define DW_AT_MIPS_linkage_name 0x2007 +#define DW_AT_MIPS_stride 0x2008 +#define DW_AT_MIPS_abstract_name 0x2009 +#define DW_AT_MIPS_clone_origin 0x200a +#define DW_AT_MIPS_has_inlines 0x200b +#define DW_AT_MIPS_stride_byte 0x200c +#define DW_AT_MIPS_stride_elem 0x200d +#define DW_AT_MIPS_ptr_dopetype 0x200e +#define DW_AT_MIPS_allocatable_dopetype 0x200f +#define DW_AT_MIPS_assumed_shape_dopetype 0x2010 +#define DW_AT_MIPS_assumed_size 0x2011 + /* GNU extensions. */ #define DW_AT_sf_names 0x2101 #define DW_AT_src_info 0x2102 @@ -234,6 +253,21 @@ #define DW_AT_GNU_all_call_sites 0x2117 #define DW_AT_GNU_all_source_call_sites 0x2118 +/* Apple extensions. */ +#define DW_AT_APPLE_optimized 0x3fe1 +#define DW_AT_APPLE_flags 0x3fe2 +#define DW_AT_APPLE_isa 0x3fe3 +#define DW_AT_APPLE_block 0x3fe4 +#define DW_AT_APPLE_major_runtime_vers 0x3fe5 +#define DW_AT_APPLE_runtime_class 0x3fe6 +#define DW_AT_APPLE_omit_frame_ptr 0x3fe7 +#define DW_AT_APPLE_property_name 0x3fe8 +#define DW_AT_APPLE_property_getter 0x3fe9 +#define DW_AT_APPLE_property_setter 0x3fea +#define DW_AT_APPLE_property_attribute 0x3feb +#define DW_AT_APPLE_objc_complete_type 0x3fec +#define DW_AT_APPLE_property 0x3fed + #define DW_FORM_addr 0x01 #define DW_FORM_block2 0x03 #define DW_FORM_block4 0x04 @@ -490,6 +524,7 @@ #define DW_LANG_UPC 0x0012 #define DW_LANG_D 0x0013 #define DW_LANG_lo_user 0x8000 +#define DW_LANG_Mips_Assembler 0x8001 #define DW_LANG_hi_user 0xffff #define DW_ID_case_sensitive 0x00 diff --git a/libdwarf/dwarf_attrval.c b/libdwarf/dwarf_attrval.c index 0dd38a491d84..9a2f791b2b40 100644 --- a/libdwarf/dwarf_attrval.c +++ b/libdwarf/dwarf_attrval.c @@ -26,7 +26,7 @@ #include "_libdwarf.h" -ELFTC_VCSID("$Id: dwarf_attrval.c 3159 2015-02-15 21:43:27Z emaste $"); +ELFTC_VCSID("$Id: dwarf_attrval.c 3509 2016-12-29 03:58:41Z emaste $"); int dwarf_attrval_flag(Dwarf_Die die, Dwarf_Half attr, Dwarf_Bool *valp, Dwarf_Error *err) @@ -145,6 +145,7 @@ dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwa Dwarf_Die die1; Dwarf_Unsigned val; Dwarf_Debug dbg; + int first; dbg = die != NULL ? die->die_dbg : NULL; @@ -155,14 +156,16 @@ dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwa *valp = 0; - if ((at = _dwarf_attr_find(die, attr)) == NULL && attr != DW_AT_type) { - DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY); - return (DW_DLV_NO_ENTRY); - } - die1 = NULL; - if (at == NULL && - (at = _dwarf_attr_find(die, DW_AT_abstract_origin)) != NULL) { + for (;;) { + if ((at = _dwarf_attr_find(die, attr)) != NULL || + attr != DW_AT_type) + break; + if ((at = _dwarf_attr_find(die, DW_AT_abstract_origin)) == + NULL && + (at = _dwarf_attr_find(die, DW_AT_specification)) == NULL) + break; + switch (at->at_form) { case DW_FORM_ref1: case DW_FORM_ref2: @@ -170,13 +173,15 @@ dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwa case DW_FORM_ref8: case DW_FORM_ref_udata: val = at->u[0].u64; - if ((die1 = _dwarf_die_find(die, val)) == NULL || - (at = _dwarf_attr_find(die1, attr)) == NULL) { - if (die1 != NULL) - dwarf_dealloc(dbg, die1, DW_DLA_DIE); + first = (die1 == NULL); + die1 = _dwarf_die_find(die, val); + if (!first) + dwarf_dealloc(dbg, die, DW_DLA_DIE); + if (die1 == NULL) { DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY); return (DW_DLV_NO_ENTRY); } + die = die1; break; default: DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD); @@ -184,6 +189,11 @@ dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwa } } + if (at == NULL) { + DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY); + return (DW_DLV_NO_ENTRY); + } + switch (at->at_form) { case DW_FORM_addr: case DW_FORM_data1: diff --git a/libdwarf/dwarf_attrval_signed.3 b/libdwarf/dwarf_attrval_signed.3 index 93d4ae0596ed..c9416bc050bc 100644 --- a/libdwarf/dwarf_attrval_signed.3 +++ b/libdwarf/dwarf_attrval_signed.3 @@ -22,9 +22,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dwarf_attrval_signed.3 2980 2014-01-21 20:15:54Z kaiwang27 $ +.\" $Id: dwarf_attrval_signed.3 3509 2016-12-29 03:58:41Z emaste $ .\" -.Dd January 18, 2014 +.Dd December 26, 2016 .Os .Dt DWARF_ATTRVAL_SIGNED 3 .Sh NAME @@ -168,17 +168,22 @@ or .Pp If the attribute named by argument .Ar attr -is not present in the debugging information entry referenced by -argument +is +.Dv DW_AT_type +and is not present in the debugging information entry referenced by argument .Ar die , and if a .Dv DW_AT_abstract_origin +or +.Dv DW_AT_specification attribute is present in the debugging information entry, function .Fn dwarf_attrval_unsigned will search for the named attribute in the debugging information entry referenced by the .Dv DW_AT_abstract_origin +or +.Dv DW_AT_specification attribute. .Sh RETURN VALUES On success, these functions returns diff --git a/libdwarf/dwarf_dump.c b/libdwarf/dwarf_dump.c index 3219fa4c0c6c..aa7ef1dfc82d 100644 --- a/libdwarf/dwarf_dump.c +++ b/libdwarf/dwarf_dump.c @@ -27,7 +27,7 @@ #include "_libdwarf.h" -ELFTC_VCSID("$Id: dwarf_dump.c 3052 2014-05-26 20:36:24Z kaiwang27 $"); +ELFTC_VCSID("$Id: dwarf_dump.c 3494 2016-09-20 17:16:13Z emaste $"); int dwarf_get_ACCESS_name(unsigned access, const char **s) @@ -262,6 +262,40 @@ dwarf_get_AT_name(unsigned attr, const char **s) *s = "DW_AT_body_begin"; break; case DW_AT_body_end: *s = "DW_AT_body_end"; break; + case DW_AT_MIPS_fde: + *s = "DW_AT_MIPS_fde"; break; + case DW_AT_MIPS_loop_begin: + *s = "DW_AT_MIPS_loop_begin"; break; + case DW_AT_MIPS_tail_loop_begin: + *s = "DW_AT_MIPS_tail_loop_begin"; break; + case DW_AT_MIPS_epilog_begin: + *s = "DW_AT_MIPS_epilog_begin"; break; + case DW_AT_MIPS_loop_unroll_factor: + *s = "DW_AT_MIPS_loop_unroll_factor"; break; + case DW_AT_MIPS_software_pipeline_depth: + *s = "DW_AT_MIPS_software_pipeline_depth"; break; + case DW_AT_MIPS_linkage_name: + *s = "DW_AT_MIPS_linkage_name"; break; + case DW_AT_MIPS_stride: + *s = "DW_AT_MIPS_stride"; break; + case DW_AT_MIPS_abstract_name: + *s = "DW_AT_MIPS_abstract_name"; break; + case DW_AT_MIPS_clone_origin: + *s = "DW_AT_MIPS_clone_origin"; break; + case DW_AT_MIPS_has_inlines: + *s = "DW_AT_MIPS_has_inlines"; break; + case DW_AT_MIPS_stride_byte: + *s = "DW_AT_MIPS_stride_byte"; break; + case DW_AT_MIPS_stride_elem: + *s = "DW_AT_MIPS_stride_elem"; break; + case DW_AT_MIPS_ptr_dopetype: + *s = "DW_AT_MIPS_ptr_dopetype"; break; + case DW_AT_MIPS_allocatable_dopetype: + *s = "DW_AT_MIPS_allocatable_dopetype"; break; + case DW_AT_MIPS_assumed_shape_dopetype: + *s = "DW_AT_MIPS_assumed_shape_dopetype"; break; + case DW_AT_MIPS_assumed_size: + *s = "DW_AT_MIPS_assumed_size"; break; case DW_AT_GNU_vector: *s = "DW_AT_GNU_vector"; break; case DW_AT_GNU_guarded_by: @@ -298,6 +332,32 @@ dwarf_get_AT_name(unsigned attr, const char **s) *s = "DW_AT_GNU_all_call_sites"; break; case DW_AT_GNU_all_source_call_sites: *s = "DW_AT_GNU_all_source_call_sites"; break; + case DW_AT_APPLE_optimized: + *s = "DW_AT_APPLE_optimized"; break; + case DW_AT_APPLE_flags: + *s = "DW_AT_APPLE_flags"; break; + case DW_AT_APPLE_isa: + *s = "DW_AT_APPLE_isa"; break; + case DW_AT_APPLE_block: + *s = "DW_AT_APPLE_block"; break; + case DW_AT_APPLE_major_runtime_vers: + *s = "DW_AT_APPLE_major_runtime_vers"; break; + case DW_AT_APPLE_runtime_class: + *s = "DW_AT_APPLE_runtime_class"; break; + case DW_AT_APPLE_omit_frame_ptr: + *s = "DW_AT_APPLE_omit_frame_ptr"; break; + case DW_AT_APPLE_property_name: + *s = "DW_AT_APPLE_property_name"; break; + case DW_AT_APPLE_property_getter: + *s = "DW_AT_APPLE_property_getter"; break; + case DW_AT_APPLE_property_setter: + *s = "DW_AT_APPLE_property_setter"; break; + case DW_AT_APPLE_property_attribute: + *s = "DW_AT_APPLE_property_attribute"; break; + case DW_AT_APPLE_objc_complete_type: + *s = "DW_AT_APPLE_objc_complete_type"; break; + case DW_AT_APPLE_property: + *s = "DW_AT_APPLE_property"; break; default: return (DW_DLV_NO_ENTRY); } @@ -730,6 +790,8 @@ dwarf_get_LANG_name(unsigned lang, const char **s) *s = "DW_LANG_D"; break; case DW_LANG_lo_user: *s = "DW_LANG_lo_user"; break; + case DW_LANG_Mips_Assembler: + *s = "DW_LANG_Mips_Assembler"; break; case DW_LANG_hi_user: *s = "DW_LANG_hi_user"; break; default: diff --git a/libelf/gelf_newehdr.3 b/libelf/gelf_newehdr.3 index 180fea9f3cb0..cba9de0c8fe5 100644 --- a/libelf/gelf_newehdr.3 +++ b/libelf/gelf_newehdr.3 @@ -21,7 +21,7 @@ .\" out of the use of this software, even if advised of the possibility of .\" such damage. .\" -.\" $Id: gelf_newehdr.3 189 2008-07-20 10:38:08Z jkoshy $ +.\" $Id: gelf_newehdr.3 3500 2016-12-04 11:08:44Z jkoshy $ .\" .Dd October 22, 2007 .Os @@ -127,6 +127,15 @@ flag on ELF descriptor .Sh RETURN VALUES These functions return a pointer to a translated header descriptor if successful, or NULL on failure. +.Sh COMPATIBILITY +The +.Fn gelf_newehdr +function uses a type of +.Ft "void *" +for its returned value. +This differs from some other implementations of the ELF(3) API, which use an +.Ft "unsigned long" +return type. .Sh ERRORS These functions can fail with the following errors: .Bl -tag -width "[ELF_E_RESOURCE]" diff --git a/libelf/gelf_newphdr.3 b/libelf/gelf_newphdr.3 index 931385e1a32e..27e561d01052 100644 --- a/libelf/gelf_newphdr.3 +++ b/libelf/gelf_newphdr.3 @@ -21,7 +21,7 @@ .\" out of the use of this software, even if advised of the possibility of .\" such damage. .\" -.\" $Id: gelf_newphdr.3 189 2008-07-20 10:38:08Z jkoshy $ +.\" $Id: gelf_newphdr.3 3500 2016-12-04 11:08:44Z jkoshy $ .\" .Dd October 22, 2007 .Os @@ -97,6 +97,15 @@ will no longer be valid. .Sh RETURN VALUES The functions a valid pointer if successful, or NULL in case an error was encountered. +.Sh COMPATIBILITY +The +.Fn gelf_newphdr +function uses a type of +.Ft "void *" +for its returned value. +This differs from some other implementations of the ELF(3) API, which use an +.Ft "unsigned long" +return type. .Sh ERRORS These functions may fail with the following errors: .Bl -tag -width "[ELF_E_RESOURCE]" diff --git a/libelftc/elftc_bfd_find_target.3 b/libelftc/elftc_bfd_find_target.3 index 2e4dbaac8362..302c319f0b83 100644 --- a/libelftc/elftc_bfd_find_target.3 +++ b/libelftc/elftc_bfd_find_target.3 @@ -21,7 +21,7 @@ .\" out of the use of this software, even if advised of the possibility of .\" such damage. .\" -.\" $Id: elftc_bfd_find_target.3 3488 2016-08-24 18:15:57Z emaste $ +.\" $Id: elftc_bfd_find_target.3 3516 2017-02-10 02:33:08Z emaste $ .\" .Dd November 30, 2011 .Os @@ -74,6 +74,7 @@ Known descriptor names and their properties include: .It Li elf32-littlearm Ta ELF Ta LSB Ta 32 .It Li elf32-littlemips Ta ELF Ta LSB Ta 32 .It Li elf32-powerpc Ta ELF Ta MSB Ta 32 +.It Li elf32-powerpc-freebsd Ta ELF Ta MSB Ta 32 .It Li elf32-powerpcle Ta ELF Ta LSB Ta 32 .It Li elf32-sh Ta ELF Ta MSB Ta 32 .It Li elf32-shl Ta ELF Ta LSB Ta 32 @@ -82,6 +83,8 @@ Known descriptor names and their properties include: .It Li elf32-shbig-linux Ta ELF Ta MSB Ta 32 .It Li elf32-shl-linux Ta ELF Ta LSB Ta 32 .It Li elf32-sparc Ta ELF Ta MSB Ta 32 +.It Li elf32-tradbigmips Ta ELF Ta MSB Ta 32 +.It Li elf32-tradlittlemips Ta ELF Ta LSB Ta 32 .It Li elf64-alpha Ta ELF Ta LSB Ta 64 .It Li elf64-alpha-freebsd Ta ELF Ta LSB Ta 64 .It Li elf64-big Ta ELF Ta MSB Ta 64 @@ -92,6 +95,7 @@ Known descriptor names and their properties include: .It Li elf64-littleaarch64 Ta ELF Ta LSB Ta 64 .It Li elf64-littlemips Ta ELF Ta LSB Ta 64 .It Li elf64-powerpc Ta ELF Ta MSB Ta 64 +.It Li elf64-powerpc-freebsd Ta ELF Ta MSB Ta 64 .It Li elf64-powerpcle Ta ELF Ta LSB Ta 64 .It Li elf64-sh64 Ta ELF Ta MSB Ta 64 .It Li elf64-sh64l Ta ELF Ta LSB Ta 64 @@ -101,6 +105,8 @@ Known descriptor names and their properties include: .It Li elf64-sh64-linux Ta ELF Ta LSB Ta 64 .It Li elf64-sparc Ta ELF Ta MSB Ta 64 .It Li elf64-sparc-freebsd Ta ELF Ta MSB Ta 64 +.It Li elf64-tradbigmips Ta ELF Ta MSB Ta 64 +.It Li elf64-tradlittlemips Ta ELF Ta LSB Ta 64 .It Li elf64-x86-64 Ta ELF Ta LSB Ta 64 .It Li elf64-x86-64-freebsd Ta ELF Ta LSB Ta 64 .It Li ihex Ta IHEX Ta - Ta - diff --git a/libelftc/libelftc_bfdtarget.c b/libelftc/libelftc_bfdtarget.c index d87d4d8b445d..48b67a00c75c 100644 --- a/libelftc/libelftc_bfdtarget.c +++ b/libelftc/libelftc_bfdtarget.c @@ -30,7 +30,7 @@ #include "_libelftc.h" -ELFTC_VCSID("$Id: libelftc_bfdtarget.c 3488 2016-08-24 18:15:57Z emaste $"); +ELFTC_VCSID("$Id: libelftc_bfdtarget.c 3516 2017-02-10 02:33:08Z emaste $"); struct _Elftc_Bfd_Target _libelftc_targets[] = { @@ -126,6 +126,15 @@ struct _Elftc_Bfd_Target _libelftc_targets[] = { .bt_machine = EM_PPC, }, + { + .bt_name = "elf32-powerpc-freebsd", + .bt_type = ETF_ELF, + .bt_byteorder = ELFDATA2MSB, + .bt_elfclass = ELFCLASS32, + .bt_machine = EM_PPC, + .bt_osabi = ELFOSABI_FREEBSD, + }, + { .bt_name = "elf32-powerpcle", .bt_type = ETF_ELF, @@ -194,6 +203,22 @@ struct _Elftc_Bfd_Target _libelftc_targets[] = { .bt_machine = EM_SPARC, }, + { + .bt_name = "elf32-tradbigmips", + .bt_type = ETF_ELF, + .bt_byteorder = ELFDATA2MSB, + .bt_elfclass = ELFCLASS32, + .bt_machine = EM_MIPS, + }, + + { + .bt_name = "elf32-tradlittlemips", + .bt_type = ETF_ELF, + .bt_byteorder = ELFDATA2LSB, + .bt_elfclass = ELFCLASS32, + .bt_machine = EM_MIPS, + }, + { .bt_name = "elf64-alpha", .bt_type = ETF_ELF, @@ -273,6 +298,15 @@ struct _Elftc_Bfd_Target _libelftc_targets[] = { .bt_machine = EM_PPC64, }, + { + .bt_name = "elf64-powerpc-freebsd", + .bt_type = ETF_ELF, + .bt_byteorder = ELFDATA2MSB, + .bt_elfclass = ELFCLASS64, + .bt_machine = EM_PPC64, + .bt_osabi = ELFOSABI_FREEBSD, + }, + { .bt_name = "elf64-powerpcle", .bt_type = ETF_ELF, @@ -350,6 +384,22 @@ struct _Elftc_Bfd_Target _libelftc_targets[] = { .bt_osabi = ELFOSABI_FREEBSD }, + { + .bt_name = "elf64-tradbigmips", + .bt_type = ETF_ELF, + .bt_byteorder = ELFDATA2MSB, + .bt_elfclass = ELFCLASS64, + .bt_machine = EM_MIPS, + }, + + { + .bt_name = "elf64-tradlittlemips", + .bt_type = ETF_ELF, + .bt_byteorder = ELFDATA2LSB, + .bt_elfclass = ELFCLASS64, + .bt_machine = EM_MIPS, + }, + { .bt_name = "elf64-x86-64", .bt_type = ETF_ELF, diff --git a/libelftc/libelftc_dem_arm.c b/libelftc/libelftc_dem_arm.c index 012819e8aade..5550505d59f1 100644 --- a/libelftc/libelftc_dem_arm.c +++ b/libelftc/libelftc_dem_arm.c @@ -37,7 +37,7 @@ #include "_libelftc.h" -ELFTC_VCSID("$Id: libelftc_dem_arm.c 3447 2016-05-03 13:32:23Z emaste $"); +ELFTC_VCSID("$Id: libelftc_dem_arm.c 3513 2016-12-29 07:04:22Z kaiwang27 $"); /** * @file cpp_demangle_arm.c @@ -68,6 +68,7 @@ struct demangle_data { }; #define SIMPLE_HASH(x,y) (64 * x + y) +#define VEC_PUSH_STR(d,s) vector_str_push((d), (s), strlen((s))) #define CPP_DEMANGLE_ARM_TRY 128 static void dest_cstring(struct cstring *); @@ -137,7 +138,7 @@ cpp_demangle_ARM(const char *org) ++d.p; /* start argument types */ - if (vector_str_push(&d.vec, "(", 1) == false) + if (VEC_PUSH_STR(&d.vec, "(") == false) goto clean; for (;;) { @@ -169,21 +170,21 @@ cpp_demangle_ARM(const char *org) goto clean; if (d.ptr == true) { - if (vector_str_push(&d.vec, "*", 1) == false) + if (VEC_PUSH_STR(&d.vec, "*") == false) goto clean; d.ptr = false; } if (d.ref == true) { - if (vector_str_push(&d.vec, "&", 1) == false) + if (VEC_PUSH_STR(&d.vec, "&") == false) goto clean; d.ref = false; } if (d.cnst == true) { - if (vector_str_push(&d.vec, " const", 6) == false) + if (VEC_PUSH_STR(&d.vec, " const") == false) goto clean; d.cnst = false; @@ -210,7 +211,7 @@ cpp_demangle_ARM(const char *org) free(arg); - if (vector_str_push(&d.vec, ", ", 2) == false) + if (VEC_PUSH_STR(&d.vec, ", ") == false) goto clean; if (++try > CPP_DEMANGLE_ARM_TRY) @@ -218,7 +219,7 @@ cpp_demangle_ARM(const char *org) } /* end argument types */ - if (vector_str_push(&d.vec, ")", 1) == false) + if (VEC_PUSH_STR(&d.vec, ")") == false) goto clean; flat: @@ -323,11 +324,10 @@ push_CTDT(const char *s, size_t l, struct vector_str *v) return (false); assert(v->size > 1); - if (vector_str_push(v, v->container[v->size - 2], - strlen(v->container[v->size - 2])) == false) + if (VEC_PUSH_STR(v, v->container[v->size - 2]) == false) return (false); - if (vector_str_push(v, "()", 2) == false) + if (VEC_PUSH_STR(v, "()") == false) return (false); return (true); @@ -429,7 +429,7 @@ read_func(struct demangle_data *d) if (read_class(d) == false) return (false); - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) return (false); } @@ -486,7 +486,7 @@ read_func_name(struct demangle_data *d) if (read_qual_name(d) == false) goto clean; - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) goto clean; if (vector_str_push(&d->vec, op_name, len) == false) @@ -508,7 +508,7 @@ read_func_name(struct demangle_data *d) if (read_class(d) == false) goto clean; - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) goto clean; if (vector_str_push(&d->vec, op_name, len) == false) @@ -553,7 +553,7 @@ read_func_ptr(struct demangle_data *d) } if (fptr.ptr == true) { - if (vector_str_push(&fptr.vec, "*", 1) == false) { + if (VEC_PUSH_STR(&fptr.vec, "*") == false) { dest_demangle_data(&fptr); return (false); @@ -563,7 +563,7 @@ read_func_ptr(struct demangle_data *d) } if (fptr.ref == true) { - if (vector_str_push(&fptr.vec, "&", 1) == false) { + if (VEC_PUSH_STR(&fptr.vec, "&") == false) { dest_demangle_data(&fptr); return (false); @@ -573,7 +573,7 @@ read_func_ptr(struct demangle_data *d) } if (fptr.cnst == true) { - if (vector_str_push(&fptr.vec, " const", 6) == false) { + if (VEC_PUSH_STR(&fptr.vec, " const") == false) { dest_demangle_data(&fptr); return (false); @@ -585,7 +585,7 @@ read_func_ptr(struct demangle_data *d) if (*fptr.p == '_') break; - if (vector_str_push(&fptr.vec, ", ", 2) == false) { + if (VEC_PUSH_STR(&fptr.vec, ", ") == false) { dest_demangle_data(&fptr); return (false); @@ -636,7 +636,7 @@ read_func_ptr(struct demangle_data *d) free(rtn_type); - if (vector_str_push(&d->vec, " (*)(", 5) == false) { + if (VEC_PUSH_STR(&d->vec, " (*)(") == false) { free(arg_type); return (false); @@ -650,7 +650,7 @@ read_func_ptr(struct demangle_data *d) free(arg_type); - return (vector_str_push(&d->vec, ")", 1)); + return (VEC_PUSH_STR(&d->vec, ")")); } static bool @@ -689,7 +689,7 @@ read_memptr(struct demangle_data *d) if (vector_str_push(&d->vec, mptr_str, len) == false) goto clean; - if (vector_str_push(&d->vec, "::*", 3) == false) + if (VEC_PUSH_STR(&d->vec, "::*") == false) goto clean; rtn = true; @@ -712,108 +712,102 @@ read_op(struct demangle_data *d) switch (SIMPLE_HASH(*(d->p), *(d->p+1))) { case SIMPLE_HASH('m', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "operator*", 9)); + return (VEC_PUSH_STR(&d->vec, "operator*")); case SIMPLE_HASH('d', 'v') : d->p += 2; - return (vector_str_push(&d->vec, "operator/", 9)); + return (VEC_PUSH_STR(&d->vec, "operator/")); case SIMPLE_HASH('m', 'd') : d->p += 2; - return (vector_str_push(&d->vec, "operator%", 9)); + return (VEC_PUSH_STR(&d->vec, "operator%")); case SIMPLE_HASH('p', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "operator+", 9)); + return (VEC_PUSH_STR(&d->vec, "operator+")); case SIMPLE_HASH('m', 'i') : d->p += 2; - return (vector_str_push(&d->vec, "operator-", 9)); + return (VEC_PUSH_STR(&d->vec, "operator-")); case SIMPLE_HASH('l', 's') : d->p += 2; - return (vector_str_push(&d->vec, "operator<<", 10)); + return (VEC_PUSH_STR(&d->vec, "operator<<")); case SIMPLE_HASH('r', 's') : d->p += 2; - return (vector_str_push(&d->vec, "operator>>", 10)); + return (VEC_PUSH_STR(&d->vec, "operator>>")); case SIMPLE_HASH('e', 'q') : d->p += 2; - return (vector_str_push(&d->vec, "operator==", 10)); + return (VEC_PUSH_STR(&d->vec, "operator==")); case SIMPLE_HASH('n', 'e') : d->p += 2; - return (vector_str_push(&d->vec, "operator!=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator!=")); case SIMPLE_HASH('l', 't') : d->p += 2; - return (vector_str_push(&d->vec, "operator<", 9)); + return (VEC_PUSH_STR(&d->vec, "operator<")); case SIMPLE_HASH('g', 't') : d->p += 2; - return (vector_str_push(&d->vec, "operator>", 9)); + return (VEC_PUSH_STR(&d->vec, "operator>")); case SIMPLE_HASH('l', 'e') : d->p += 2; - return (vector_str_push(&d->vec, "operator<=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator<=")); case SIMPLE_HASH('g', 'e') : d->p += 2; - return (vector_str_push(&d->vec, "operator>=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator>=")); case SIMPLE_HASH('a', 'd') : d->p += 2; if (*d->p == 'v') { ++d->p; - return (vector_str_push(&d->vec, "operator/=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator/=")); } else - return (vector_str_push(&d->vec, "operator&", 9)); + return (VEC_PUSH_STR(&d->vec, "operator&")); case SIMPLE_HASH('o', 'r') : d->p += 2; - return (vector_str_push(&d->vec, "operator|", 9)); + return (VEC_PUSH_STR(&d->vec, "operator|")); case SIMPLE_HASH('e', 'r') : d->p += 2; - return (vector_str_push(&d->vec, "operator^", 9)); + return (VEC_PUSH_STR(&d->vec, "operator^")); case SIMPLE_HASH('a', 'a') : d->p += 2; if (*d->p == 'd') { ++d->p; - return (vector_str_push(&d->vec, "operator&=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator&=")); } else - return (vector_str_push(&d->vec, "operator&&", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator&&")); case SIMPLE_HASH('o', 'o') : d->p += 2; - return (vector_str_push(&d->vec, "operator||", 10)); + return (VEC_PUSH_STR(&d->vec, "operator||")); case SIMPLE_HASH('n', 't') : d->p += 2; - return (vector_str_push(&d->vec, "operator!", 9)); + return (VEC_PUSH_STR(&d->vec, "operator!")); case SIMPLE_HASH('c', 'o') : d->p += 2; - return (vector_str_push(&d->vec, "operator~", 9)); + return (VEC_PUSH_STR(&d->vec, "operator~")); case SIMPLE_HASH('p', 'p') : d->p += 2; - return (vector_str_push(&d->vec, "operator++", 10)); + return (VEC_PUSH_STR(&d->vec, "operator++")); case SIMPLE_HASH('m', 'm') : d->p += 2; - return (vector_str_push(&d->vec, "operator--", 10)); + return (VEC_PUSH_STR(&d->vec, "operator--")); case SIMPLE_HASH('a', 's') : d->p += 2; - return (vector_str_push(&d->vec, "operator=", 9)); + return (VEC_PUSH_STR(&d->vec, "operator=")); case SIMPLE_HASH('r', 'f') : d->p += 2; - return (vector_str_push(&d->vec, "operator->", 10)); + return (VEC_PUSH_STR(&d->vec, "operator->")); case SIMPLE_HASH('a', 'p') : /* apl */ if (*(d->p + 2) != 'l') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator+=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator+=")); case SIMPLE_HASH('a', 'm') : d->p += 2; if (*d->p == 'i') { ++d->p; - return (vector_str_push(&d->vec, "operator-=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator-=")); } else if (*d->p == 'u') { ++d->p; - return (vector_str_push(&d->vec, "operator*=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator*=")); } else if (*d->p == 'd') { ++d->p; - return (vector_str_push(&d->vec, "operator%=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator%=")); } return (false); @@ -823,40 +817,40 @@ read_op(struct demangle_data *d) return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator<<=", 11)); + return (VEC_PUSH_STR(&d->vec, "operator<<=")); case SIMPLE_HASH('a', 'r') : /* ars */ if (*(d->p + 2) != 's') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator>>=", 11)); + return (VEC_PUSH_STR(&d->vec, "operator>>=")); case SIMPLE_HASH('a', 'o') : /* aor */ if (*(d->p + 2) != 'r') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator|=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator|=")); case SIMPLE_HASH('a', 'e') : /* aer */ if (*(d->p + 2) != 'r') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator^=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator^=")); case SIMPLE_HASH('c', 'm') : d->p += 2; - return (vector_str_push(&d->vec, "operator,", 9)); + return (VEC_PUSH_STR(&d->vec, "operator,")); case SIMPLE_HASH('r', 'm') : d->p += 2; - return (vector_str_push(&d->vec, "operator->*", 11)); + return (VEC_PUSH_STR(&d->vec, "operator->*")); case SIMPLE_HASH('c', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "()", 2)); + return (VEC_PUSH_STR(&d->vec, "()")); case SIMPLE_HASH('v', 'c') : d->p += 2; - return (vector_str_push(&d->vec, "[]", 2)); + return (VEC_PUSH_STR(&d->vec, "[]")); case SIMPLE_HASH('c', 't') : d->p += 4; d->type = ENCODE_OP_CT; @@ -883,11 +877,10 @@ read_op(struct demangle_data *d) return (false); case SIMPLE_HASH('n', 'w') : d->p += 2; - return (vector_str_push(&d->vec, "operator new()", 14)); + return (VEC_PUSH_STR(&d->vec, "operator new()")); case SIMPLE_HASH('d', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "operator delete()", - 17)); + return (VEC_PUSH_STR(&d->vec, "operator delete()")); case SIMPLE_HASH('o', 'p') : /* __op__ */ d->p += 2; @@ -962,13 +955,13 @@ read_op_user(struct demangle_data *d) if (vector_str_push(&d->vec, from_str, from_len) == false) goto clean; - if (vector_str_push(&d->vec, "::operator ", 11) == false) + if (VEC_PUSH_STR(&d->vec, "::operator ") == false) return (false); if (vector_str_push(&d->vec, to_str, to_len) == false) goto clean; - rtn = vector_str_push(&d->vec, "()", 2); + rtn = VEC_PUSH_STR(&d->vec, "()"); clean: free(to_str); free(from_str); @@ -1000,7 +993,7 @@ read_qual_name(struct demangle_data *d) if (read_class(d) == false) return (false); - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) return (false); } @@ -1029,12 +1022,10 @@ read_subst(struct demangle_data *d) d->p = str; - if (vector_str_push(&d->vec, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->vec, d->arg.container[idx - 1]) == false) return (-1); - if (vector_str_push(&d->arg, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->arg, d->arg.container[idx - 1]) == false) return (-1); if (*d->p == '\0') @@ -1073,16 +1064,14 @@ read_subst_iter(struct demangle_data *d) d->p = str; for (i = 0; i < repeat ; ++i) { - if (vector_str_push(&d->vec, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->vec, d->arg.container[idx - 1]) == false) return (-1); - if (vector_str_push(&d->arg, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->arg, d->arg.container[idx - 1]) == false) return (-1); if (i != repeat - 1 && - vector_str_push(&d->vec, ", ", 2) == false) + VEC_PUSH_STR(&d->vec, ", ") == false) return (-1); } @@ -1108,7 +1097,7 @@ read_type(struct demangle_data *d) case 'U' : ++d->p; - if (vector_str_push(&d->vec, "unsigned ", 9) == false) + if (VEC_PUSH_STR(&d->vec, "unsigned ") == false) return (false); break; @@ -1118,7 +1107,7 @@ read_type(struct demangle_data *d) if (*d->p == 'P') d->cnst = true; else { - if (vector_str_push(&d->vec, "const ", 6) == + if (VEC_PUSH_STR(&d->vec, "const ") == false) return (false); } @@ -1127,14 +1116,14 @@ read_type(struct demangle_data *d) case 'V' : ++d->p; - if (vector_str_push(&d->vec, "volatile ", 9) == false) + if (VEC_PUSH_STR(&d->vec, "volatile ") == false) return (false); break; case 'S' : ++d->p; - if (vector_str_push(&d->vec, "signed ", 7) == false) + if (VEC_PUSH_STR(&d->vec, "signed ") == false) return (false); break; @@ -1185,39 +1174,39 @@ read_type(struct demangle_data *d) case 'v' : ++d->p; - return (vector_str_push(&d->vec, "void", 4)); + return (VEC_PUSH_STR(&d->vec, "void")); case 'c' : ++d->p; - return (vector_str_push(&d->vec, "char", 4)); + return (VEC_PUSH_STR(&d->vec, "char")); case 's' : ++d->p; - return (vector_str_push(&d->vec, "short", 5)); + return (VEC_PUSH_STR(&d->vec, "short")); case 'i' : ++d->p; - return (vector_str_push(&d->vec, "int", 3)); + return (VEC_PUSH_STR(&d->vec, "int")); case 'l' : ++d->p; - return (vector_str_push(&d->vec, "long", 4)); + return (VEC_PUSH_STR(&d->vec, "long")); case 'f' : ++d->p; - return (vector_str_push(&d->vec, "float", 5)); + return (VEC_PUSH_STR(&d->vec, "float")); case 'd': ++d->p; - return (vector_str_push(&d->vec, "double", 6)); + return (VEC_PUSH_STR(&d->vec, "double")); case 'r': ++d->p; - return (vector_str_push(&d->vec, "long double", 11)); + return (VEC_PUSH_STR(&d->vec, "long double")); case 'e': ++d->p; - return (vector_str_push(&d->vec, "...", 3)); + return (VEC_PUSH_STR(&d->vec, "...")); default: return (false); }; diff --git a/libelftc/libelftc_dem_gnu2.c b/libelftc/libelftc_dem_gnu2.c index 5dff1ca2a2b3..5c77b67ce848 100644 --- a/libelftc/libelftc_dem_gnu2.c +++ b/libelftc/libelftc_dem_gnu2.c @@ -37,7 +37,7 @@ #include "_libelftc.h" -ELFTC_VCSID("$Id: libelftc_dem_gnu2.c 3447 2016-05-03 13:32:23Z emaste $"); +ELFTC_VCSID("$Id: libelftc_dem_gnu2.c 3513 2016-12-29 07:04:22Z kaiwang27 $"); /** * @file cpp_demangle_gnu2.c @@ -66,6 +66,7 @@ struct demangle_data { }; #define SIMPLE_HASH(x,y) (64 * x + y) +#define VEC_PUSH_STR(d,s) vector_str_push((d), (s), strlen((s))) #define CPP_DEMANGLE_GNU2_TRY 128 static void dest_cstring(struct cstring *); @@ -126,7 +127,7 @@ cpp_demangle_gnu2(const char *org) if (push_CTDT("::~", 3, &d.vec) == false) goto clean; - if (vector_str_push(&d.vec, "(void)", 6) == false) + if (VEC_PUSH_STR(&d.vec, "(void)") == false) goto clean; goto flat; @@ -141,7 +142,7 @@ cpp_demangle_gnu2(const char *org) ++d.p; else if (*d.p == '\0') { if (d.class_name == true) { - if (vector_str_push(&d.vec, "(void)", 6) == false) + if (VEC_PUSH_STR(&d.vec, "(void)") == false) goto clean; goto flat; @@ -150,7 +151,7 @@ cpp_demangle_gnu2(const char *org) } /* start argument types */ - if (vector_str_push(&d.vec, "(", 1) == false) + if (VEC_PUSH_STR(&d.vec, "(") == false) goto clean; for (;;) { @@ -182,21 +183,21 @@ cpp_demangle_gnu2(const char *org) goto clean; if (d.ptr == true) { - if (vector_str_push(&d.vec, "*", 1) == false) + if (VEC_PUSH_STR(&d.vec, "*") == false) goto clean; d.ptr = false; } if (d.ref == true) { - if (vector_str_push(&d.vec, "&", 1) == false) + if (VEC_PUSH_STR(&d.vec, "&") == false) goto clean; d.ref = false; } if (d.cnst == true) { - if (vector_str_push(&d.vec, " const", 6) == false) + if (VEC_PUSH_STR(&d.vec, " const") == false) goto clean; d.cnst = false; @@ -223,7 +224,7 @@ cpp_demangle_gnu2(const char *org) free(arg); - if (vector_str_push(&d.vec, ", ", 2) == false) + if (VEC_PUSH_STR(&d.vec, ", ") == false) goto clean; if (++try > CPP_DEMANGLE_GNU2_TRY) @@ -231,10 +232,10 @@ cpp_demangle_gnu2(const char *org) } /* end argument types */ - if (vector_str_push(&d.vec, ")", 1) == false) + if (VEC_PUSH_STR(&d.vec, ")") == false) goto clean; flat: - if (d.cnst_fn == true && vector_str_push(&d.vec, " const", 6) == false) + if (d.cnst_fn == true && VEC_PUSH_STR(&d.vec, " const") == false) goto clean; rtn = vector_str_get_flat(&d.vec, NULL); @@ -410,8 +411,7 @@ push_CTDT(const char *s, size_t l, struct vector_str *v) assert(v->size > 1); - return (vector_str_push(v, v->container[v->size - 2], - strlen(v->container[v->size - 2]))); + return (VEC_PUSH_STR(v, v->container[v->size - 2])); } static bool @@ -518,7 +518,7 @@ read_func(struct demangle_data *d) if (read_class(d) == false) return (false); - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) return (false); } @@ -563,7 +563,7 @@ read_func_name(struct demangle_data *d) /* not good condition, start function name with '__' */ d->type = ENCODE_FUNC; - if (vector_str_push(&d->vec, "__", 2) == false) + if (VEC_PUSH_STR(&d->vec, "__") == false) return (false); return (read_func(d)); @@ -601,7 +601,7 @@ read_func_name(struct demangle_data *d) if (read_qual_name(d) == false) goto clean; - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) goto clean; if (vector_str_push(&d->vec, op_name, len) == false) @@ -623,7 +623,7 @@ read_func_name(struct demangle_data *d) if (read_class(d) == false) goto clean; - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) goto clean; if (vector_str_push(&d->vec, op_name, len) == false) @@ -665,7 +665,7 @@ read_func_name(struct demangle_data *d) return (false); } - return (vector_str_push(&d->vec, " virtual table", 14)); + return (VEC_PUSH_STR(&d->vec, " virtual table")); } else return (read_func(d)); clean: @@ -702,7 +702,7 @@ read_func_ptr(struct demangle_data *d) } if (fptr.ptr == true) { - if (vector_str_push(&fptr.vec, "*", 1) == false) { + if (VEC_PUSH_STR(&fptr.vec, "*") == false) { dest_demangle_data(&fptr); return (false); @@ -712,7 +712,7 @@ read_func_ptr(struct demangle_data *d) } if (fptr.ref == true) { - if (vector_str_push(&fptr.vec, "&", 1) == false) { + if (VEC_PUSH_STR(&fptr.vec, "&") == false) { dest_demangle_data(&fptr); return (false); @@ -722,7 +722,7 @@ read_func_ptr(struct demangle_data *d) } if (fptr.cnst == true) { - if (vector_str_push(&fptr.vec, " const", 6) == false) { + if (VEC_PUSH_STR(&fptr.vec, " const") == false) { dest_demangle_data(&fptr); return (false); @@ -734,7 +734,7 @@ read_func_ptr(struct demangle_data *d) if (*fptr.p == '_') break; - if (vector_str_push(&fptr.vec, ", ", 2) == false) { + if (VEC_PUSH_STR(&fptr.vec, ", ") == false) { dest_demangle_data(&fptr); return (false); @@ -785,7 +785,7 @@ read_func_ptr(struct demangle_data *d) free(rtn_type); - if (vector_str_push(&d->vec, " (*)(", 5) == false) { + if (VEC_PUSH_STR(&d->vec, " (*)(") == false) { free(arg_type); return (false); @@ -799,7 +799,7 @@ read_func_ptr(struct demangle_data *d) free(arg_type); - return (vector_str_push(&d->vec, ")", 1)); + return (VEC_PUSH_STR(&d->vec, ")")); } static bool @@ -836,7 +836,7 @@ read_memptr(struct demangle_data *d) if (vector_str_push(&d->vec, mptr_str, len) == false) goto clean; - if (vector_str_push(&d->vec, "::*", 3) == false) + if (VEC_PUSH_STR(&d->vec, "::*") == false) goto clean; rtn = true; @@ -859,108 +859,102 @@ read_op(struct demangle_data *d) switch (SIMPLE_HASH(*(d->p), *(d->p+1))) { case SIMPLE_HASH('m', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "operator*", 9)); + return (VEC_PUSH_STR(&d->vec, "operator*")); case SIMPLE_HASH('d', 'v') : d->p += 2; - return (vector_str_push(&d->vec, "operator/", 9)); + return (VEC_PUSH_STR(&d->vec, "operator/")); case SIMPLE_HASH('m', 'd') : d->p += 2; - return (vector_str_push(&d->vec, "operator%", 9)); + return (VEC_PUSH_STR(&d->vec, "operator%")); case SIMPLE_HASH('p', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "operator+", 9)); + return (VEC_PUSH_STR(&d->vec, "operator+")); case SIMPLE_HASH('m', 'i') : d->p += 2; - return (vector_str_push(&d->vec, "operator-", 9)); + return (VEC_PUSH_STR(&d->vec, "operator-")); case SIMPLE_HASH('l', 's') : d->p += 2; - return (vector_str_push(&d->vec, "operator<<", 10)); + return (VEC_PUSH_STR(&d->vec, "operator<<")); case SIMPLE_HASH('r', 's') : d->p += 2; - return (vector_str_push(&d->vec, "operator>>", 10)); + return (VEC_PUSH_STR(&d->vec, "operator>>")); case SIMPLE_HASH('e', 'q') : d->p += 2; - return (vector_str_push(&d->vec, "operator==", 10)); + return (VEC_PUSH_STR(&d->vec, "operator==")); case SIMPLE_HASH('n', 'e') : d->p += 2; - return (vector_str_push(&d->vec, "operator!=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator!=")); case SIMPLE_HASH('l', 't') : d->p += 2; - return (vector_str_push(&d->vec, "operator<", 9)); + return (VEC_PUSH_STR(&d->vec, "operator<")); case SIMPLE_HASH('g', 't') : d->p += 2; - return (vector_str_push(&d->vec, "operator>", 9)); + return (VEC_PUSH_STR(&d->vec, "operator>")); case SIMPLE_HASH('l', 'e') : d->p += 2; - return (vector_str_push(&d->vec, "operator<=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator<=")); case SIMPLE_HASH('g', 'e') : d->p += 2; - return (vector_str_push(&d->vec, "operator>=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator>=")); case SIMPLE_HASH('a', 'd') : d->p += 2; if (*d->p == 'v') { ++d->p; - return (vector_str_push(&d->vec, "operator/=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator/=")); } else - return (vector_str_push(&d->vec, "operator&", 9)); + return (VEC_PUSH_STR(&d->vec, "operator&")); case SIMPLE_HASH('o', 'r') : d->p += 2; - return (vector_str_push(&d->vec, "operator|", 9)); + return (VEC_PUSH_STR(&d->vec, "operator|")); case SIMPLE_HASH('e', 'r') : d->p += 2; - return (vector_str_push(&d->vec, "operator^", 9)); + return (VEC_PUSH_STR(&d->vec, "operator^")); case SIMPLE_HASH('a', 'a') : d->p += 2; if (*d->p == 'd') { ++d->p; - return (vector_str_push(&d->vec, "operator&=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator&=")); } else - return (vector_str_push(&d->vec, "operator&&", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator&&")); case SIMPLE_HASH('o', 'o') : d->p += 2; - return (vector_str_push(&d->vec, "operator||", 10)); + return (VEC_PUSH_STR(&d->vec, "operator||")); case SIMPLE_HASH('n', 't') : d->p += 2; - return (vector_str_push(&d->vec, "operator!", 9)); + return (VEC_PUSH_STR(&d->vec, "operator!")); case SIMPLE_HASH('c', 'o') : d->p += 2; - return (vector_str_push(&d->vec, "operator~", 9)); + return (VEC_PUSH_STR(&d->vec, "operator~")); case SIMPLE_HASH('p', 'p') : d->p += 2; - return (vector_str_push(&d->vec, "operator++", 10)); + return (VEC_PUSH_STR(&d->vec, "operator++")); case SIMPLE_HASH('m', 'm') : d->p += 2; - return (vector_str_push(&d->vec, "operator--", 10)); + return (VEC_PUSH_STR(&d->vec, "operator--")); case SIMPLE_HASH('a', 's') : d->p += 2; - return (vector_str_push(&d->vec, "operator=", 9)); + return (VEC_PUSH_STR(&d->vec, "operator=")); case SIMPLE_HASH('r', 'f') : d->p += 2; - return (vector_str_push(&d->vec, "operator->", 10)); + return (VEC_PUSH_STR(&d->vec, "operator->")); case SIMPLE_HASH('a', 'p') : /* apl */ if (*(d->p + 2) != 'l') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator+=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator+=")); case SIMPLE_HASH('a', 'm') : d->p += 2; if (*d->p == 'i') { ++d->p; - return (vector_str_push(&d->vec, "operator-=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator-=")); } else if (*d->p == 'u') { ++d->p; - return (vector_str_push(&d->vec, "operator*=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator*=")); } else if (*d->p == 'd') { ++d->p; - return (vector_str_push(&d->vec, "operator%=", - 10)); + return (VEC_PUSH_STR(&d->vec, "operator%=")); } return (false); @@ -970,47 +964,46 @@ read_op(struct demangle_data *d) return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator<<=", 11)); + return (VEC_PUSH_STR(&d->vec, "operator<<=")); case SIMPLE_HASH('a', 'r') : /* ars */ if (*(d->p + 2) != 's') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator>>=", 11)); + return (VEC_PUSH_STR(&d->vec, "operator>>=")); case SIMPLE_HASH('a', 'o') : /* aor */ if (*(d->p + 2) != 'r') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator|=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator|=")); case SIMPLE_HASH('a', 'e') : /* aer */ if (*(d->p + 2) != 'r') return (false); d->p += 3; - return (vector_str_push(&d->vec, "operator^=", 10)); + return (VEC_PUSH_STR(&d->vec, "operator^=")); case SIMPLE_HASH('c', 'm') : d->p += 2; - return (vector_str_push(&d->vec, "operator,", 9)); + return (VEC_PUSH_STR(&d->vec, "operator,")); case SIMPLE_HASH('r', 'm') : d->p += 2; - return (vector_str_push(&d->vec, "operator->*", 11)); + return (VEC_PUSH_STR(&d->vec, "operator->*")); case SIMPLE_HASH('c', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "()", 2)); + return (VEC_PUSH_STR(&d->vec, "()")); case SIMPLE_HASH('v', 'c') : d->p += 2; - return (vector_str_push(&d->vec, "[]", 2)); + return (VEC_PUSH_STR(&d->vec, "[]")); case SIMPLE_HASH('n', 'w') : d->p += 2; - return (vector_str_push(&d->vec, "operator new()", 14)); + return (VEC_PUSH_STR(&d->vec, "operator new()")); case SIMPLE_HASH('d', 'l') : d->p += 2; - return (vector_str_push(&d->vec, "operator delete()", - 17)); + return (VEC_PUSH_STR(&d->vec, "operator delete()")); case SIMPLE_HASH('o', 'p') : /* __op__ */ d->p += 2; @@ -1025,7 +1018,7 @@ read_op(struct demangle_data *d) if (read_type(d) == false) return (false); - return (vector_str_push(&d->vec, " type_info function", 19)); + return (VEC_PUSH_STR(&d->vec, " type_info function")); case SIMPLE_HASH('t', 'i') : d->p += 2; d->type = ENCODE_OP_TI; @@ -1033,7 +1026,7 @@ read_op(struct demangle_data *d) if (read_type(d) == false) return (false); - return (vector_str_push(&d->vec, " type_info node", 15)); + return (VEC_PUSH_STR(&d->vec, " type_info node")); default : return (false); }; @@ -1099,13 +1092,13 @@ read_op_user(struct demangle_data *d) if (vector_str_push(&d->vec, from_str, from_len) == false) goto clean; - if (vector_str_push(&d->vec, "::operator ", 11) == false) + if (VEC_PUSH_STR(&d->vec, "::operator ") == false) goto clean; if (vector_str_push(&d->vec, to_str, to_len) == false) goto clean; - rtn = vector_str_push(&d->vec, "()", 2); + rtn = VEC_PUSH_STR(&d->vec, "()"); clean: free(to_str); free(from_str); @@ -1137,7 +1130,7 @@ read_qual_name(struct demangle_data *d) if (read_class(d) == false) return (false); - if (vector_str_push(&d->vec, "::", 2) == false) + if (VEC_PUSH_STR(&d->vec, "::") == false) return (false); } @@ -1166,12 +1159,10 @@ read_subst(struct demangle_data *d) d->p = str; - if (vector_str_push(&d->vec, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->vec, d->arg.container[idx - 1]) == false) return (-1); - if (vector_str_push(&d->arg, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->arg, d->arg.container[idx - 1]) == false) return (-1); if (*d->p == '\0') @@ -1210,16 +1201,14 @@ read_subst_iter(struct demangle_data *d) d->p = str; for (i = 0; i < repeat ; ++i) { - if (vector_str_push(&d->vec, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->vec, d->arg.container[idx - 1]) == false) return (-1); - if (vector_str_push(&d->arg, d->arg.container[idx - 1], - strlen(d->arg.container[idx - 1])) == false) + if (VEC_PUSH_STR(&d->arg, d->arg.container[idx - 1]) == false) return (-1); if (i != repeat - 1 && - vector_str_push(&d->vec, ", ", 2) == false) + VEC_PUSH_STR(&d->vec, ", ") == false) return (-1); } @@ -1245,7 +1234,7 @@ read_type(struct demangle_data *d) case 'U' : ++d->p; - if (vector_str_push(&d->vec, "unsigned ", 9) == false) + if (VEC_PUSH_STR(&d->vec, "unsigned ") == false) return (false); break; @@ -1255,7 +1244,7 @@ read_type(struct demangle_data *d) if (*d->p == 'P') d->cnst = true; else { - if (vector_str_push(&d->vec, "const ", 6) == + if (VEC_PUSH_STR(&d->vec, "const ") == false) return (false); } @@ -1264,14 +1253,14 @@ read_type(struct demangle_data *d) case 'V' : ++d->p; - if (vector_str_push(&d->vec, "volatile ", 9) == false) + if (VEC_PUSH_STR(&d->vec, "volatile ") == false) return (false); break; case 'S' : ++d->p; - if (vector_str_push(&d->vec, "signed ", 7) == false) + if (VEC_PUSH_STR(&d->vec, "signed ") == false) return (false); break; @@ -1322,51 +1311,51 @@ read_type(struct demangle_data *d) case 'v' : ++d->p; - return (vector_str_push(&d->vec, "void", 4)); + return (VEC_PUSH_STR(&d->vec, "void")); case 'b': ++d->p; - return(vector_str_push(&d->vec, "bool", 4)); + return(VEC_PUSH_STR(&d->vec, "bool")); case 'c' : ++d->p; - return (vector_str_push(&d->vec, "char", 4)); + return (VEC_PUSH_STR(&d->vec, "char")); case 's' : ++d->p; - return (vector_str_push(&d->vec, "short", 5)); + return (VEC_PUSH_STR(&d->vec, "short")); case 'i' : ++d->p; - return (vector_str_push(&d->vec, "int", 3)); + return (VEC_PUSH_STR(&d->vec, "int")); case 'l' : ++d->p; - return (vector_str_push(&d->vec, "long", 4)); + return (VEC_PUSH_STR(&d->vec, "long")); case 'f' : ++d->p; - return (vector_str_push(&d->vec, "float", 5)); + return (VEC_PUSH_STR(&d->vec, "float")); case 'd': ++d->p; - return (vector_str_push(&d->vec, "double", 6)); + return (VEC_PUSH_STR(&d->vec, "double")); case 'r': ++d->p; - return (vector_str_push(&d->vec, "long double", 11)); + return (VEC_PUSH_STR(&d->vec, "long double")); case 'e': ++d->p; - return (vector_str_push(&d->vec, "...", 3)); + return (VEC_PUSH_STR(&d->vec, "...")); case 'w': ++d->p; - return (vector_str_push(&d->vec, "wchar_t", 7)); + return (VEC_PUSH_STR(&d->vec, "wchar_t")); case 'x': ++d->p; - return (vector_str_push(&d->vec, "long long", 9)); + return (VEC_PUSH_STR(&d->vec, "long long")); default: return (false); }; diff --git a/libelftc/libelftc_dem_gnu3.c b/libelftc/libelftc_dem_gnu3.c index c3d3f4b7f594..bd571228fb1a 100644 --- a/libelftc/libelftc_dem_gnu3.c +++ b/libelftc/libelftc_dem_gnu3.c @@ -36,7 +36,7 @@ #include "_libelftc.h" -ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3480 2016-07-24 23:38:41Z emaste $"); +ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3512 2016-12-29 07:04:19Z kaiwang27 $"); /** * @file cpp_demangle.c @@ -93,6 +93,8 @@ struct cpp_demangle_data { #define FLOAT_EXTENED_BYTES 10 #define SIMPLE_HASH(x,y) (64 * x + y) +#define DEM_PUSH_STR(d,s) cpp_demangle_push_str((d), (s), strlen((s))) +#define VEC_PUSH_STR(d,s) vector_str_push((d), (s), strlen((s))) static void cpp_demangle_data_dest(struct cpp_demangle_data *); static int cpp_demangle_data_init(struct cpp_demangle_data *, @@ -217,13 +219,13 @@ cpp_demangle_gnu3(const char *org) if (ddata.output.size == 0) goto clean; - if (ddata.paren && !vector_str_push(&ddata.output, ")", 1)) + if (ddata.paren && !VEC_PUSH_STR(&ddata.output, ")")) goto clean; - if (ddata.mem_vat && !vector_str_push(&ddata.output, " volatile", 9)) + if (ddata.mem_vat && !VEC_PUSH_STR(&ddata.output, " volatile")) goto clean; - if (ddata.mem_cst && !vector_str_push(&ddata.output, " const", 6)) + if (ddata.mem_cst && !VEC_PUSH_STR(&ddata.output, " const")) goto clean; - if (ddata.mem_rst && !vector_str_push(&ddata.output, " restrict", 9)) + if (ddata.mem_rst && !VEC_PUSH_STR(&ddata.output, " restrict")) goto clean; rtn = vector_str_get_flat(&ddata.output, (size_t *) NULL); @@ -398,7 +400,7 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, if (type_str != NULL) { if (!vector_str_init(&subst_v)) return (0); - if (!vector_str_push(&subst_v, type_str, strlen(type_str))) + if (!VEC_PUSH_STR(&subst_v, type_str)) goto clean; } @@ -406,10 +408,10 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, while (idx > 0) { switch (v->q_container[idx - 1]) { case TYPE_PTR: - if (!cpp_demangle_push_str(ddata, "*", 1)) + if (!DEM_PUSH_STR(ddata, "*")) goto clean; if (type_str != NULL) { - if (!vector_str_push(&subst_v, "*", 1)) + if (!VEC_PUSH_STR(&subst_v, "*")) goto clean; if (!cpp_demangle_push_subst_v(ddata, &subst_v)) @@ -418,10 +420,10 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, break; case TYPE_REF: - if (!cpp_demangle_push_str(ddata, "&", 1)) + if (!DEM_PUSH_STR(ddata, "&")) goto clean; if (type_str != NULL) { - if (!vector_str_push(&subst_v, "&", 1)) + if (!VEC_PUSH_STR(&subst_v, "&")) goto clean; if (!cpp_demangle_push_subst_v(ddata, &subst_v)) @@ -430,10 +432,10 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, break; case TYPE_CMX: - if (!cpp_demangle_push_str(ddata, " complex", 8)) + if (!DEM_PUSH_STR(ddata, " complex")) goto clean; if (type_str != NULL) { - if (!vector_str_push(&subst_v, " complex", 8)) + if (!VEC_PUSH_STR(&subst_v, " complex")) goto clean; if (!cpp_demangle_push_subst_v(ddata, &subst_v)) @@ -442,7 +444,7 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, break; case TYPE_IMG: - if (!cpp_demangle_push_str(ddata, " imaginary", 10)) + if (!DEM_PUSH_STR(ddata, " imaginary")) goto clean; if (type_str != NULL) { if (!vector_str_push(&subst_v, " imaginary", @@ -466,14 +468,13 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, snprintf(buf, e_len + 2, " %s", v->ext_name.container[e_idx]); - if (!cpp_demangle_push_str(ddata, buf, e_len + 1)) { + if (!DEM_PUSH_STR(ddata, buf)) { free(buf); goto clean; } if (type_str != NULL) { - if (!vector_str_push(&subst_v, buf, - e_len + 1)) { + if (!VEC_PUSH_STR(&subst_v, buf)) { free(buf); goto clean; } @@ -488,10 +489,10 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, break; case TYPE_RST: - if (!cpp_demangle_push_str(ddata, " restrict", 9)) + if (!DEM_PUSH_STR(ddata, " restrict")) goto clean; if (type_str != NULL) { - if (!vector_str_push(&subst_v, " restrict", 9)) + if (!VEC_PUSH_STR(&subst_v, " restrict")) goto clean; if (!cpp_demangle_push_subst_v(ddata, &subst_v)) @@ -500,10 +501,10 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, break; case TYPE_VAT: - if (!cpp_demangle_push_str(ddata, " volatile", 9)) + if (!DEM_PUSH_STR(ddata, " volatile")) goto clean; if (type_str != NULL) { - if (!vector_str_push(&subst_v, " volatile", 9)) + if (!VEC_PUSH_STR(&subst_v, " volatile")) goto clean; if (!cpp_demangle_push_subst_v(ddata, &subst_v)) @@ -512,10 +513,10 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, break; case TYPE_CST: - if (!cpp_demangle_push_str(ddata, " const", 6)) + if (!DEM_PUSH_STR(ddata, " const")) goto clean; if (type_str != NULL) { - if (!vector_str_push(&subst_v, " const", 6)) + if (!VEC_PUSH_STR(&subst_v, " const")) goto clean; if (!cpp_demangle_push_subst_v(ddata, &subst_v)) @@ -534,13 +535,12 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, goto clean; snprintf(buf, e_len + 12, " __vector(%s)", v->ext_name.container[e_idx]); - if (!cpp_demangle_push_str(ddata, buf, e_len + 11)) { + if (!DEM_PUSH_STR(ddata, buf)) { free(buf); goto clean; } if (type_str != NULL) { - if (!vector_str_push(&subst_v, buf, - e_len + 11)) { + if (!VEC_PUSH_STR(&subst_v, buf)) { free(buf); goto clean; } @@ -617,7 +617,7 @@ cpp_demangle_read_array(struct cpp_demangle_data *ddata) if (!cpp_demangle_read_type(ddata, 0)) return (0); - if (!cpp_demangle_push_str(ddata, "[]", 2)) + if (!DEM_PUSH_STR(ddata, "[]")) return (0); } else { if (ELFTC_ISDIGIT(*ddata->cur) != 0) { @@ -632,11 +632,11 @@ cpp_demangle_read_array(struct cpp_demangle_data *ddata) return (0); if (!cpp_demangle_read_type(ddata, 0)) return (0); - if (!cpp_demangle_push_str(ddata, "[", 1)) + if (!DEM_PUSH_STR(ddata, "[")) return (0); if (!cpp_demangle_push_str(ddata, num, num_len)) return (0); - if (!cpp_demangle_push_str(ddata, "]", 1)) + if (!DEM_PUSH_STR(ddata, "]")) return (0); } else { p_idx = ddata->output.size; @@ -664,7 +664,7 @@ cpp_demangle_read_array(struct cpp_demangle_data *ddata) free(exp); return (0); } - if (!cpp_demangle_push_str(ddata, "[", 1)) { + if (!DEM_PUSH_STR(ddata, "[")) { free(exp); return (0); } @@ -672,7 +672,7 @@ cpp_demangle_read_array(struct cpp_demangle_data *ddata) free(exp); return (0); } - if (!cpp_demangle_push_str(ddata, "]", 1)) { + if (!DEM_PUSH_STR(ddata, "]")) { free(exp); return (0); } @@ -708,10 +708,10 @@ cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata) switch (*(++ddata->cur)) { case '0': ddata->cur += 2; - return (cpp_demangle_push_str(ddata, "false", 5)); + return (DEM_PUSH_STR(ddata, "false")); case '1': ddata->cur += 2; - return (cpp_demangle_push_str(ddata, "true", 4)); + return (DEM_PUSH_STR(ddata, "true")); default: return (0); } @@ -748,7 +748,7 @@ cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata) case 'x': case 'y': if (*(++ddata->cur) == 'n') { - if (!cpp_demangle_push_str(ddata, "-", 1)) + if (!DEM_PUSH_STR(ddata, "-")) return (0); ++ddata->cur; } @@ -1151,7 +1151,7 @@ cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c, if (!cpp_demangle_read_type(ddata, 0)) return (0); if (*ddata->cur != 'E') { - if (!cpp_demangle_push_str(ddata, "(", 1)) + if (!DEM_PUSH_STR(ddata, "(")) return (0); if (vector_read_cmd_find(&ddata->cmd, READ_PTRMEM)) { if ((class_type_size = ddata->class_type.size) == 0) @@ -1165,7 +1165,7 @@ cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c, if (!cpp_demangle_push_str(ddata, class_type, class_type_len)) return (0); - if (!cpp_demangle_push_str(ddata, "::*", 3)) + if (!DEM_PUSH_STR(ddata, "::*")) return (0); ++ddata->func_type; } else { @@ -1177,7 +1177,7 @@ cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c, return (0); } - if (!cpp_demangle_push_str(ddata, ")(", 2)) + if (!DEM_PUSH_STR(ddata, ")(")) return (0); limit = 0; @@ -1199,7 +1199,7 @@ cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c, return (0); } - if (!cpp_demangle_push_str(ddata, ")", 1)) + if (!DEM_PUSH_STR(ddata, ")")) return (0); } @@ -1222,7 +1222,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) /* special name */ switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { case SIMPLE_HASH('G', 'A'): - if (!cpp_demangle_push_str(ddata, "hidden alias for ", 17)) + if (!DEM_PUSH_STR(ddata, "hidden alias for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1230,7 +1230,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) return (cpp_demangle_read_encoding(ddata)); case SIMPLE_HASH('G', 'R'): - if (!cpp_demangle_push_str(ddata, "reference temporary #", 21)) + if (!DEM_PUSH_STR(ddata, "reference temporary #")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1240,11 +1240,11 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) rtn = 0; if (!cpp_demangle_read_number_as_string(ddata, &num_str)) goto clean1; - if (!cpp_demangle_push_str(ddata, num_str, strlen(num_str))) + if (!DEM_PUSH_STR(ddata, num_str)) goto clean2; - if (!cpp_demangle_push_str(ddata, " for ", 5)) + if (!DEM_PUSH_STR(ddata, " for ")) goto clean2; - if (!cpp_demangle_push_str(ddata, name, strlen(name))) + if (!DEM_PUSH_STR(ddata, name)) goto clean2; rtn = 1; clean2: @@ -1259,14 +1259,12 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) return (0); switch (*ddata->cur) { case 'n': - if (!cpp_demangle_push_str(ddata, - "non-transaction clone for ", 26)) + if (!DEM_PUSH_STR(ddata, "non-transaction clone for ")) return (0); break; case 't': default: - if (!cpp_demangle_push_str(ddata, - "transaction clone for ", 22)) + if (!DEM_PUSH_STR(ddata, "transaction clone for ")) return (0); break; } @@ -1275,15 +1273,15 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('G', 'V'): /* sentry object for 1 time init */ - if (!cpp_demangle_push_str(ddata, "guard variable for ", 20)) + if (!DEM_PUSH_STR(ddata, "guard variable for ")) return (0); ddata->cur += 2; break; case SIMPLE_HASH('T', 'c'): /* virtual function covariant override thunk */ - if (!cpp_demangle_push_str(ddata, - "virtual function covariant override ", 36)) + if (!DEM_PUSH_STR(ddata, + "virtual function covariant override ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1296,8 +1294,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'C'): /* construction vtable */ - if (!cpp_demangle_push_str(ddata, "construction vtable for ", - 24)) + if (!DEM_PUSH_STR(ddata, "construction vtable for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1311,9 +1308,9 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) goto clean3; if (!cpp_demangle_read_type(ddata, 0)) goto clean3; - if (!cpp_demangle_push_str(ddata, "-in-", 4)) + if (!DEM_PUSH_STR(ddata, "-in-")) goto clean3; - if (!cpp_demangle_push_str(ddata, type, strlen(type))) + if (!DEM_PUSH_STR(ddata, type)) goto clean3; rtn = 1; clean3: @@ -1326,7 +1323,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'F'): /* typeinfo fn */ - if (!cpp_demangle_push_str(ddata, "typeinfo fn for ", 16)) + if (!DEM_PUSH_STR(ddata, "typeinfo fn for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1335,8 +1332,8 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'h'): /* virtual function non-virtual override thunk */ - if (!cpp_demangle_push_str(ddata, - "virtual function non-virtual override ", 38)) + if (!DEM_PUSH_STR(ddata, + "virtual function non-virtual override ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1347,8 +1344,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'H'): /* TLS init function */ - if (!cpp_demangle_push_str(ddata, "TLS init function for ", - 22)) + if (!DEM_PUSH_STR(ddata, "TLS init function for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1357,7 +1353,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'I'): /* typeinfo structure */ - if (!cpp_demangle_push_str(ddata, "typeinfo for ", 13)) + if (!DEM_PUSH_STR(ddata, "typeinfo for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1366,7 +1362,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'J'): /* java class */ - if (!cpp_demangle_push_str(ddata, "java Class for ", 15)) + if (!DEM_PUSH_STR(ddata, "java Class for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1375,7 +1371,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'S'): /* RTTI name (NTBS) */ - if (!cpp_demangle_push_str(ddata, "typeinfo name for ", 18)) + if (!DEM_PUSH_STR(ddata, "typeinfo name for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1384,7 +1380,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'T'): /* VTT table */ - if (!cpp_demangle_push_str(ddata, "VTT for ", 8)) + if (!DEM_PUSH_STR(ddata, "VTT for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1393,8 +1389,8 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'v'): /* virtual function virtual override thunk */ - if (!cpp_demangle_push_str(ddata, - "virtual function virtual override ", 34)) + if (!DEM_PUSH_STR(ddata, + "virtual function virtual override ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1405,7 +1401,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'V'): /* virtual table */ - if (!cpp_demangle_push_str(ddata, "vtable for ", 12)) + if (!DEM_PUSH_STR(ddata, "vtable for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1414,8 +1410,7 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) case SIMPLE_HASH('T', 'W'): /* TLS wrapper function */ - if (!cpp_demangle_push_str(ddata, "TLS wrapper function for ", - 25)) + if (!DEM_PUSH_STR(ddata, "TLS wrapper function for ")) return (0); ddata->cur += 2; if (*ddata->cur == '\0') @@ -1450,14 +1445,14 @@ cpp_demangle_read_local_name(struct cpp_demangle_data *ddata) if (*(++ddata->cur) == '\0') return (0); if (ddata->paren == true) { - if (!cpp_demangle_push_str(ddata, ")", 1)) + if (!DEM_PUSH_STR(ddata, ")")) return (0); ddata->paren = false; } if (*ddata->cur == 's') ++ddata->cur; else { - if (!cpp_demangle_push_str(ddata, "::", 2)) + if (!DEM_PUSH_STR(ddata, "::")) return (0); if (!cpp_demangle_read_name(ddata)) return (0); @@ -1639,9 +1634,9 @@ cpp_demangle_read_nested_name(struct cpp_demangle_data *ddata) break; else if (*ddata->cur != 'I' && *ddata->cur != 'C' && *ddata->cur != 'D') { - if (!cpp_demangle_push_str(ddata, "::", 2)) + if (!DEM_PUSH_STR(ddata, "::")) goto clean; - if (!vector_str_push(&v, "::", 2)) + if (!VEC_PUSH_STR(&v, "::")) goto clean; } if (limit++ > CPP_DEMANGLE_TRY_LIMIT) @@ -1719,7 +1714,7 @@ cpp_demangle_read_nv_offset(struct cpp_demangle_data *ddata) if (ddata == NULL) return (0); - if (!cpp_demangle_push_str(ddata, "offset : ", 9)) + if (!DEM_PUSH_STR(ddata, "offset : ")) return (0); return (cpp_demangle_read_offset_number(ddata)); @@ -1765,14 +1760,14 @@ cpp_demangle_read_offset_number(struct cpp_demangle_data *ddata) while (*ddata->cur != '_') ++ddata->cur; - if (negative && !cpp_demangle_push_str(ddata, "-", 1)) + if (negative && !DEM_PUSH_STR(ddata, "-")) return (0); assert(start != NULL); if (!cpp_demangle_push_str(ddata, start, ddata->cur - start)) return (0); - if (!cpp_demangle_push_str(ddata, " ", 1)) + if (!DEM_PUSH_STR(ddata, " ")) return (0); ++ddata->cur; @@ -1815,11 +1810,11 @@ cpp_demangle_read_pointer_to_member(struct cpp_demangle_data *ddata) goto clean3; if (p_func_type == ddata->func_type) { - if (!cpp_demangle_push_str(ddata, " ", 1)) + if (!DEM_PUSH_STR(ddata, " ")) goto clean3; if (!cpp_demangle_push_str(ddata, class_type, class_type_len)) goto clean3; - if (!cpp_demangle_push_str(ddata, "::*", 3)) + if (!DEM_PUSH_STR(ddata, "::*")) goto clean3; } @@ -1848,7 +1843,7 @@ cpp_demangle_read_sname(struct cpp_demangle_data *ddata) return (0); if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0)) - err = cpp_demangle_push_str(ddata, "(anonymous namespace)", 21); + err = DEM_PUSH_STR(ddata, "(anonymous namespace)"); else err = cpp_demangle_push_str(ddata, ddata->cur, len); @@ -1877,7 +1872,7 @@ cpp_demangle_read_subst(struct cpp_demangle_data *ddata) switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { case SIMPLE_HASH('S', 'a'): /* std::allocator */ - if (cpp_demangle_push_str(ddata, "std::allocator", 14) == 0) + if (!DEM_PUSH_STR(ddata, "std::allocator")) return (0); ddata->cur += 2; if (*ddata->cur == 'I') @@ -1887,7 +1882,7 @@ cpp_demangle_read_subst(struct cpp_demangle_data *ddata) case SIMPLE_HASH('S', 'b'): /* std::basic_string */ - if (!cpp_demangle_push_str(ddata, "std::basic_string", 17)) + if (!DEM_PUSH_STR(ddata, "std::basic_string")) return (0); ddata->cur += 2; if (*ddata->cur == 'I') @@ -1897,7 +1892,7 @@ cpp_demangle_read_subst(struct cpp_demangle_data *ddata) case SIMPLE_HASH('S', 'd'): /* std::basic_iostream > */ - if (!cpp_demangle_push_str(ddata, "std::basic_iostream", 19)) + if (!DEM_PUSH_STR(ddata, "std::basic_iostream")) return (0); ddata->last_sname = "basic_iostream"; ddata->cur += 2; @@ -1908,7 +1903,7 @@ cpp_demangle_read_subst(struct cpp_demangle_data *ddata) case SIMPLE_HASH('S', 'i'): /* std::basic_istream > */ - if (!cpp_demangle_push_str(ddata, "std::basic_istream", 18)) + if (!DEM_PUSH_STR(ddata, "std::basic_istream")) return (0); ddata->last_sname = "basic_istream"; ddata->cur += 2; @@ -1919,7 +1914,7 @@ cpp_demangle_read_subst(struct cpp_demangle_data *ddata) case SIMPLE_HASH('S', 'o'): /* std::basic_ostream > */ - if (!cpp_demangle_push_str(ddata, "std::basic_ostream", 18)) + if (!DEM_PUSH_STR(ddata, "std::basic_ostream")) return (0); ddata->last_sname = "basic_ostream"; ddata->cur += 2; @@ -1935,7 +1930,7 @@ cpp_demangle_read_subst(struct cpp_demangle_data *ddata) * * a.k.a std::string */ - if (!cpp_demangle_push_str(ddata, "std::string", 11)) + if (!DEM_PUSH_STR(ddata, "std::string")) return (0); ddata->last_sname = "string"; ddata->cur += 2; @@ -1993,10 +1988,10 @@ cpp_demangle_read_subst_std(struct cpp_demangle_data *ddata) subst_str = NULL; rtn = 0; - if (!cpp_demangle_push_str(ddata, "std::", 5)) + if (!DEM_PUSH_STR(ddata, "std::")) goto clean; - if (!vector_str_push(&v, "std::", 5)) + if (!VEC_PUSH_STR(&v, "std::")) goto clean; ddata->cur += 2; @@ -2115,7 +2110,7 @@ cpp_demangle_read_tmpl_args(struct cpp_demangle_data *ddata) if (!vector_read_cmd_push(&ddata->cmd, READ_TMPL)) return (0); - if (!cpp_demangle_push_str(ddata, "<", 1)) + if (!DEM_PUSH_STR(ddata, "<")) return (0); limit = 0; @@ -2140,13 +2135,13 @@ cpp_demangle_read_tmpl_args(struct cpp_demangle_data *ddata) size = v->size; assert(size > 0); if (!strncmp(v->container[size - 1], ">", 1)) { - if (!cpp_demangle_push_str(ddata, " >", 2)) + if (!DEM_PUSH_STR(ddata, " >")) return (0); - } else if (!cpp_demangle_push_str(ddata, ">", 1)) + } else if (!DEM_PUSH_STR(ddata, ">")) return (0); break; } else if (*ddata->cur != 'I' && - !cpp_demangle_push_str(ddata, ", ", 2)) + !DEM_PUSH_STR(ddata, ", ")) return (0); if (limit++ > CPP_DEMANGLE_TRY_LIMIT) @@ -2213,7 +2208,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) output = &ddata->output_tmp; } else if (delimit == 1) { if (ddata->paren == false) { - if (!cpp_demangle_push_str(ddata, "(", 1)) + if (!DEM_PUSH_STR(ddata, "(")) return (0); if (ddata->output.size < 2) return (0); @@ -2228,7 +2223,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) if (ddata->pfirst) ddata->pfirst = false; else if (*ddata->cur != 'I' && - !cpp_demangle_push_str(ddata, ", ", 2)) + !DEM_PUSH_STR(ddata, ", ")) return (0); } @@ -2250,7 +2245,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) switch (*ddata->cur) { case 'a': /* signed char */ - if (!cpp_demangle_push_str(ddata, "signed char", 11)) + if (!DEM_PUSH_STR(ddata, "signed char")) goto clean; ++ddata->cur; goto rtn; @@ -2264,7 +2259,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'b': /* bool */ - if (!cpp_demangle_push_str(ddata, "bool", 4)) + if (!DEM_PUSH_STR(ddata, "bool")) goto clean; ++ddata->cur; goto rtn; @@ -2278,14 +2273,14 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'c': /* char */ - if (!cpp_demangle_push_str(ddata, "char", 4)) + if (!DEM_PUSH_STR(ddata, "char")) goto clean; ++ddata->cur; goto rtn; case 'd': /* double */ - if (!cpp_demangle_push_str(ddata, "double", 6)) + if (!DEM_PUSH_STR(ddata, "double")) goto clean; ++ddata->cur; goto rtn; @@ -2295,44 +2290,43 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) switch (*ddata->cur) { case 'd': /* IEEE 754r decimal floating point (64 bits) */ - if (!cpp_demangle_push_str(ddata, "decimal64", 9)) + if (!DEM_PUSH_STR(ddata, "decimal64")) goto clean; ++ddata->cur; break; case 'e': /* IEEE 754r decimal floating point (128 bits) */ - if (!cpp_demangle_push_str(ddata, "decimal128", 10)) + if (!DEM_PUSH_STR(ddata, "decimal128")) goto clean; ++ddata->cur; break; case 'f': /* IEEE 754r decimal floating point (32 bits) */ - if (!cpp_demangle_push_str(ddata, "decimal32", 9)) + if (!DEM_PUSH_STR(ddata, "decimal32")) goto clean; ++ddata->cur; break; case 'h': /* IEEE 754r half-precision floating point (16 bits) */ - if (!cpp_demangle_push_str(ddata, "half", 4)) + if (!DEM_PUSH_STR(ddata, "half")) goto clean; ++ddata->cur; break; case 'i': /* char32_t */ - if (!cpp_demangle_push_str(ddata, "char32_t", 8)) + if (!DEM_PUSH_STR(ddata, "char32_t")) goto clean; ++ddata->cur; break; case 'n': /* std::nullptr_t (i.e., decltype(nullptr)) */ - if (!cpp_demangle_push_str(ddata, "decltype(nullptr)", - 17)) + if (!DEM_PUSH_STR(ddata, "decltype(nullptr)")) goto clean; ++ddata->cur; break; case 's': /* char16_t */ - if (!cpp_demangle_push_str(ddata, "char16_t", 8)) + if (!DEM_PUSH_STR(ddata, "char16_t")) goto clean; ++ddata->cur; break; @@ -2344,15 +2338,13 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) if (!cpp_demangle_read_expression_flat(ddata, &exp_str)) goto clean; - if (!vector_str_push(&v.ext_name, exp_str, - strlen(exp_str))) + if (!VEC_PUSH_STR(&v.ext_name, exp_str)) goto clean; } else { if (!cpp_demangle_read_number_as_string(ddata, &num_str)) goto clean; - if (!vector_str_push(&v.ext_name, num_str, - strlen(num_str))) + if (!VEC_PUSH_STR(&v.ext_name, num_str)) goto clean; } if (*ddata->cur != '_') @@ -2368,14 +2360,14 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'e': /* long double */ - if (!cpp_demangle_push_str(ddata, "long double", 11)) + if (!DEM_PUSH_STR(ddata, "long double")) goto clean; ++ddata->cur; goto rtn; case 'f': /* float */ - if (!cpp_demangle_push_str(ddata, "float", 5)) + if (!DEM_PUSH_STR(ddata, "float")) goto clean; ++ddata->cur; goto rtn; @@ -2389,7 +2381,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'g': /* __float128 */ - if (!cpp_demangle_push_str(ddata, "__float128", 10)) + if (!DEM_PUSH_STR(ddata, "__float128")) goto clean; ++ddata->cur; goto rtn; @@ -2403,21 +2395,21 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'h': /* unsigned char */ - if (!cpp_demangle_push_str(ddata, "unsigned char", 13)) + if (!DEM_PUSH_STR(ddata, "unsigned char")) goto clean; ++ddata->cur; goto rtn; case 'i': /* int */ - if (!cpp_demangle_push_str(ddata, "int", 3)) + if (!DEM_PUSH_STR(ddata, "int")) goto clean; ++ddata->cur; goto rtn; case 'j': /* unsigned int */ - if (!cpp_demangle_push_str(ddata, "unsigned int", 12)) + if (!DEM_PUSH_STR(ddata, "unsigned int")) goto clean; ++ddata->cur; goto rtn; @@ -2431,14 +2423,14 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'l': /* long */ - if (!cpp_demangle_push_str(ddata, "long", 4)) + if (!DEM_PUSH_STR(ddata, "long")) goto clean; ++ddata->cur; goto rtn; case 'm': /* unsigned long */ - if (!cpp_demangle_push_str(ddata, "unsigned long", 13)) + if (!DEM_PUSH_STR(ddata, "unsigned long")) goto clean; ++ddata->cur; @@ -2453,14 +2445,14 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'n': /* __int128 */ - if (!cpp_demangle_push_str(ddata, "__int128", 8)) + if (!DEM_PUSH_STR(ddata, "__int128")) goto clean; ++ddata->cur; goto rtn; case 'o': /* unsigned __int128 */ - if (!cpp_demangle_push_str(ddata, "unsigned __int128", 17)) + if (!DEM_PUSH_STR(ddata, "unsigned __int128")) goto clean; ++ddata->cur; goto rtn; @@ -2488,7 +2480,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 's': /* short, local string */ - if (!cpp_demangle_push_str(ddata, "short", 5)) + if (!DEM_PUSH_STR(ddata, "short")) goto clean; ++ddata->cur; goto rtn; @@ -2502,7 +2494,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 't': /* unsigned short */ - if (!cpp_demangle_push_str(ddata, "unsigned short", 14)) + if (!DEM_PUSH_STR(ddata, "unsigned short")) goto clean; ++ddata->cur; goto rtn; @@ -2537,7 +2529,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'v': /* void */ - if (!cpp_demangle_push_str(ddata, "void", 4)) + if (!DEM_PUSH_STR(ddata, "void")) goto clean; ++ddata->cur; goto rtn; @@ -2551,28 +2543,28 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) case 'w': /* wchar_t */ - if (!cpp_demangle_push_str(ddata, "wchar_t", 7)) + if (!DEM_PUSH_STR(ddata, "wchar_t")) goto clean; ++ddata->cur; goto rtn; case 'x': /* long long */ - if (!cpp_demangle_push_str(ddata, "long long", 9)) + if (!DEM_PUSH_STR(ddata, "long long")) goto clean; ++ddata->cur; goto rtn; case 'y': /* unsigned long long */ - if (!cpp_demangle_push_str(ddata, "unsigned long long", 18)) + if (!DEM_PUSH_STR(ddata, "unsigned long long")) goto clean; ++ddata->cur; goto rtn; case 'z': /* ellipsis */ - if (!cpp_demangle_push_str(ddata, "ellipsis", 8)) + if (!DEM_PUSH_STR(ddata, "...")) goto clean; ++ddata->cur; goto rtn; @@ -2609,7 +2601,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) if (--ddata->push_head > 0) return (1); - if (!vector_str_push(&ddata->output_tmp, " ", 1)) + if (!VEC_PUSH_STR(&ddata->output_tmp, " ")) return (0); if (!vector_str_push_vector_head(&ddata->output, @@ -2620,7 +2612,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) if (!vector_str_init(&ddata->output_tmp)) return (0); - if (!cpp_demangle_push_str(ddata, "(", 1)) + if (!DEM_PUSH_STR(ddata, "(")) return (0); ddata->paren = true; @@ -2685,358 +2677,357 @@ cpp_demangle_read_uqname(struct cpp_demangle_data *ddata) switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { case SIMPLE_HASH('a', 'a'): /* operator && */ - if (!cpp_demangle_push_str(ddata, "operator&&", 10)) + if (!DEM_PUSH_STR(ddata, "operator&&")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('a', 'd'): /* operator & (unary) */ - if (!cpp_demangle_push_str(ddata, "operator&", 9)) + if (!DEM_PUSH_STR(ddata, "operator&")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('a', 'n'): /* operator & */ - if (!cpp_demangle_push_str(ddata, "operator&", 9)) + if (!DEM_PUSH_STR(ddata, "operator&")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('a', 'N'): /* operator &= */ - if (!cpp_demangle_push_str(ddata, "operator&=", 10)) + if (!DEM_PUSH_STR(ddata, "operator&=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('a', 'S'): /* operator = */ - if (!cpp_demangle_push_str(ddata, "operator=", 9)) + if (!DEM_PUSH_STR(ddata, "operator=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('c', 'l'): /* operator () */ - if (!cpp_demangle_push_str(ddata, "operator()", 10)) + if (!DEM_PUSH_STR(ddata, "operator()")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('c', 'm'): /* operator , */ - if (!cpp_demangle_push_str(ddata, "operator,", 9)) + if (!DEM_PUSH_STR(ddata, "operator,")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('c', 'o'): /* operator ~ */ - if (!cpp_demangle_push_str(ddata, "operator~", 9)) + if (!DEM_PUSH_STR(ddata, "operator~")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('c', 'v'): /* operator (cast) */ - if (!cpp_demangle_push_str(ddata, "operator(cast)", 14)) + if (!DEM_PUSH_STR(ddata, "operator(cast)")) return (0); ddata->cur += 2; return (cpp_demangle_read_type(ddata, 1)); case SIMPLE_HASH('d', 'a'): /* operator delete [] */ - if (!cpp_demangle_push_str(ddata, "operator delete []", 18)) + if (!DEM_PUSH_STR(ddata, "operator delete []")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('d', 'e'): /* operator * (unary) */ - if (!cpp_demangle_push_str(ddata, "operator*", 9)) + if (!DEM_PUSH_STR(ddata, "operator*")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('d', 'l'): /* operator delete */ - if (!cpp_demangle_push_str(ddata, "operator delete", 15)) + if (!DEM_PUSH_STR(ddata, "operator delete")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('d', 'v'): /* operator / */ - if (!cpp_demangle_push_str(ddata, "operator/", 9)) + if (!DEM_PUSH_STR(ddata, "operator/")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('d', 'V'): /* operator /= */ - if (!cpp_demangle_push_str(ddata, "operator/=", 10)) + if (!DEM_PUSH_STR(ddata, "operator/=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('e', 'o'): /* operator ^ */ - if (!cpp_demangle_push_str(ddata, "operator^", 9)) + if (!DEM_PUSH_STR(ddata, "operator^")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('e', 'O'): /* operator ^= */ - if (!cpp_demangle_push_str(ddata, "operator^=", 10)) + if (!DEM_PUSH_STR(ddata, "operator^=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('e', 'q'): /* operator == */ - if (!cpp_demangle_push_str(ddata, "operator==", 10)) + if (!DEM_PUSH_STR(ddata, "operator==")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('g', 'e'): /* operator >= */ - if (!cpp_demangle_push_str(ddata, "operator>=", 10)) + if (!DEM_PUSH_STR(ddata, "operator>=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('g', 't'): /* operator > */ - if (!cpp_demangle_push_str(ddata, "operator>", 9)) + if (!DEM_PUSH_STR(ddata, "operator>")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('i', 'x'): /* operator [] */ - if (!cpp_demangle_push_str(ddata, "operator[]", 10)) + if (!DEM_PUSH_STR(ddata, "operator[]")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('l', 'e'): /* operator <= */ - if (!cpp_demangle_push_str(ddata, "operator<=", 10)) + if (!DEM_PUSH_STR(ddata, "operator<=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('l', 's'): /* operator << */ - if (!cpp_demangle_push_str(ddata, "operator<<", 10)) + if (!DEM_PUSH_STR(ddata, "operator<<")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('l', 'S'): /* operator <<= */ - if (!cpp_demangle_push_str(ddata, "operator<<=", 11)) + if (!DEM_PUSH_STR(ddata, "operator<<=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('l', 't'): /* operator < */ - if (!cpp_demangle_push_str(ddata, "operator<", 9)) + if (!DEM_PUSH_STR(ddata, "operator<")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('m', 'i'): /* operator - */ - if (!cpp_demangle_push_str(ddata, "operator-", 9)) + if (!DEM_PUSH_STR(ddata, "operator-")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('m', 'I'): /* operator -= */ - if (!cpp_demangle_push_str(ddata, "operator-=", 10)) + if (!DEM_PUSH_STR(ddata, "operator-=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('m', 'l'): /* operator * */ - if (!cpp_demangle_push_str(ddata, "operator*", 9)) + if (!DEM_PUSH_STR(ddata, "operator*")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('m', 'L'): /* operator *= */ - if (!cpp_demangle_push_str(ddata, "operator*=", 10)) + if (!DEM_PUSH_STR(ddata, "operator*=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('m', 'm'): /* operator -- */ - if (!cpp_demangle_push_str(ddata, "operator--", 10)) + if (!DEM_PUSH_STR(ddata, "operator--")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('n', 'a'): /* operator new[] */ - if (!cpp_demangle_push_str(ddata, "operator new []", 15)) + if (!DEM_PUSH_STR(ddata, "operator new []")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('n', 'e'): /* operator != */ - if (!cpp_demangle_push_str(ddata, "operator!=", 10)) + if (!DEM_PUSH_STR(ddata, "operator!=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('n', 'g'): /* operator - (unary) */ - if (!cpp_demangle_push_str(ddata, "operator-", 9)) + if (!DEM_PUSH_STR(ddata, "operator-")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('n', 't'): /* operator ! */ - if (!cpp_demangle_push_str(ddata, "operator!", 9)) + if (!DEM_PUSH_STR(ddata, "operator!")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('n', 'w'): /* operator new */ - if (!cpp_demangle_push_str(ddata, "operator new", 12)) + if (!DEM_PUSH_STR(ddata, "operator new")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('o', 'o'): /* operator || */ - if (!cpp_demangle_push_str(ddata, "operator||", 10)) + if (!DEM_PUSH_STR(ddata, "operator||")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('o', 'r'): /* operator | */ - if (!cpp_demangle_push_str(ddata, "operator|", 9)) + if (!DEM_PUSH_STR(ddata, "operator|")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('o', 'R'): /* operator |= */ - if (!cpp_demangle_push_str(ddata, "operator|=", 10)) + if (!DEM_PUSH_STR(ddata, "operator|=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('p', 'l'): /* operator + */ - if (!cpp_demangle_push_str(ddata, "operator+", 9)) + if (!DEM_PUSH_STR(ddata, "operator+")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('p', 'L'): /* operator += */ - if (!cpp_demangle_push_str(ddata, "operator+=", 10)) + if (!DEM_PUSH_STR(ddata, "operator+=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('p', 'm'): /* operator ->* */ - if (!cpp_demangle_push_str(ddata, "operator->*", 11)) + if (!DEM_PUSH_STR(ddata, "operator->*")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('p', 'p'): /* operator ++ */ - if (!cpp_demangle_push_str(ddata, "operator++", 10)) + if (!DEM_PUSH_STR(ddata, "operator++")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('p', 's'): /* operator + (unary) */ - if (!cpp_demangle_push_str(ddata, "operator+", 9)) + if (!DEM_PUSH_STR(ddata, "operator+")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('p', 't'): /* operator -> */ - if (!cpp_demangle_push_str(ddata, "operator->", 10)) + if (!DEM_PUSH_STR(ddata, "operator->")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('q', 'u'): /* operator ? */ - if (!cpp_demangle_push_str(ddata, "operator?", 9)) + if (!DEM_PUSH_STR(ddata, "operator?")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('r', 'm'): /* operator % */ - if (!cpp_demangle_push_str(ddata, "operator%", 9)) + if (!DEM_PUSH_STR(ddata, "operator%")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('r', 'M'): /* operator %= */ - if (!cpp_demangle_push_str(ddata, "operator%=", 10)) + if (!DEM_PUSH_STR(ddata, "operator%=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('r', 's'): /* operator >> */ - if (!cpp_demangle_push_str(ddata, "operator>>", 10)) + if (!DEM_PUSH_STR(ddata, "operator>>")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('r', 'S'): /* operator >>= */ - if (!cpp_demangle_push_str(ddata, "operator>>=", 11)) + if (!DEM_PUSH_STR(ddata, "operator>>=")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('r', 'z'): /* operator sizeof */ - if (!cpp_demangle_push_str(ddata, "operator sizeof ", 16)) + if (!DEM_PUSH_STR(ddata, "operator sizeof ")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('s', 'r'): /* scope resolution operator */ - if (!cpp_demangle_push_str(ddata, "scope resolution operator ", - 26)) + if (!DEM_PUSH_STR(ddata, "scope resolution operator ")) return (0); ddata->cur += 2; return (1); case SIMPLE_HASH('s', 'v'): /* operator sizeof */ - if (!cpp_demangle_push_str(ddata, "operator sizeof ", 16)) + if (!DEM_PUSH_STR(ddata, "operator sizeof ")) return (0); ddata->cur += 2; return (1); @@ -3044,8 +3035,7 @@ cpp_demangle_read_uqname(struct cpp_demangle_data *ddata) /* vendor extened operator */ if (*ddata->cur == 'v' && ELFTC_ISDIGIT(*(ddata->cur + 1))) { - if (!cpp_demangle_push_str(ddata, "vendor extened operator ", - 24)) + if (!DEM_PUSH_STR(ddata, "vendor extened operator ")) return (0); if (!cpp_demangle_push_str(ddata, ddata->cur + 1, 1)) return (0); @@ -3064,7 +3054,7 @@ cpp_demangle_read_uqname(struct cpp_demangle_data *ddata) return (0); if ((len = strlen(ddata->last_sname)) == 0) return (0); - if (!cpp_demangle_push_str(ddata, "::", 2)) + if (!DEM_PUSH_STR(ddata, "::")) return (0); if (!cpp_demangle_push_str(ddata, ddata->last_sname, len)) return (0); @@ -3080,7 +3070,7 @@ cpp_demangle_read_uqname(struct cpp_demangle_data *ddata) return (0); if ((len = strlen(ddata->last_sname)) == 0) return (0); - if (!cpp_demangle_push_str(ddata, "::~", 3)) + if (!DEM_PUSH_STR(ddata, "::~")) return (0); if (!cpp_demangle_push_str(ddata, ddata->last_sname, len)) return (0); @@ -3135,13 +3125,13 @@ cpp_demangle_read_v_offset(struct cpp_demangle_data *ddata) if (ddata == NULL) return (0); - if (!cpp_demangle_push_str(ddata, "offset : ", 9)) + if (!DEM_PUSH_STR(ddata, "offset : ")) return (0); if (!cpp_demangle_read_offset_number(ddata)) return (0); - if (!cpp_demangle_push_str(ddata, "virtual offset : ", 17)) + if (!DEM_PUSH_STR(ddata, "virtual offset : ")) return (0); return (!cpp_demangle_read_offset_number(ddata)); diff --git a/nm/nm.c b/nm/nm.c index ebb42cab9871..493f3a80b408 100644 --- a/nm/nm.c +++ b/nm/nm.c @@ -48,7 +48,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: nm.c 3472 2016-05-17 20:11:16Z emaste $"); +ELFTC_VCSID("$Id: nm.c 3504 2016-12-17 15:33:16Z kaiwang27 $"); /* symbol information list */ STAILQ_HEAD(sym_head, sym_entry); @@ -1186,7 +1186,7 @@ read_elf(Elf *elf, const char *filename, Elf_Kind kind) } if (!elf_getshnum(elf, &shnum)) { if ((e_err = elf_errno()) != 0) - warnx("%s: %s", OBJNAME, elf_errmsg(e_err)); + warnx("%s: %s", OBJNAME, "File format not recognized"); else warnx("%s: cannot get section number", OBJNAME); rtn = 1; diff --git a/readelf/readelf.c b/readelf/readelf.c index 6da2ed28e05f..2ef5c71d82dd 100644 --- a/readelf/readelf.c +++ b/readelf/readelf.c @@ -47,7 +47,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: readelf.c 3484 2016-08-03 13:36:49Z emaste $"); +ELFTC_VCSID("$Id: readelf.c 3519 2017-04-09 23:15:58Z kaiwang27 $"); /* * readelf(1) options. @@ -644,6 +644,9 @@ phdr_type(unsigned int mach, unsigned int ptype) case PT_GNU_EH_FRAME: return "GNU_EH_FRAME"; case PT_GNU_STACK: return "GNU_STACK"; case PT_GNU_RELRO: return "GNU_RELRO"; + case PT_OPENBSD_RANDOMIZE: return "OPENBSD_RANDOMIZE"; + case PT_OPENBSD_WXNEEDED: return "OPENBSD_WXNEEDED"; + case PT_OPENBSD_BOOTDATA: return "OPENBSD_BOOTDATA"; default: if (ptype >= PT_LOOS && ptype <= PT_HIOS) snprintf(s_ptype, sizeof(s_ptype), "LOOS+%#x", @@ -709,6 +712,7 @@ section_type(unsigned int mach, unsigned int stype) case SHT_MIPS_EH_REGION: return "MIPS_EH_REGION"; case SHT_MIPS_XLATE_OLD: return "MIPS_XLATE_OLD"; case SHT_MIPS_PDR_EXCEPTION: return "MIPS_PDR_EXCEPTION"; + case SHT_MIPS_ABIFLAGS: return "MIPS_ABIFLAGS"; default: break; } @@ -934,6 +938,7 @@ dt_type(unsigned int mach, unsigned int dtype) case DT_SUNW_RTLDINF: return "SUNW_RTLDINF"; case DT_SUNW_FILTER: return "SUNW_FILTER"; case DT_SUNW_CAP: return "SUNW_CAP"; + case DT_SUNW_ASLR: return "SUNW_ASLR"; case DT_CHECKSUM: return "CHECKSUM"; case DT_PLTPADSZ: return "PLTPADSZ"; case DT_MOVEENT: return "MOVEENT"; @@ -2103,7 +2108,7 @@ dwarf_reg(unsigned int mach, unsigned int reg) static void dump_ehdr(struct readelf *re) { - size_t shnum, shstrndx; + size_t phnum, shnum, shstrndx; int i; printf("ELF Header:\n"); @@ -2165,7 +2170,13 @@ dump_ehdr(struct readelf *re) re->ehdr.e_phentsize); /* e_phnum. */ - printf("%-37s%u\n", " Number of program headers:", re->ehdr.e_phnum); + printf("%-37s%u", " Number of program headers:", re->ehdr.e_phnum); + if (re->ehdr.e_phnum == PN_XNUM) { + /* Extended program header numbering is in use. */ + if (elf_getphnum(re->elf, &phnum)) + printf(" (%zu)", phnum); + } + putchar('\n'); /* e_shentsize. */ printf("%-37s%u (bytes)\n", " Size of section headers:", @@ -4077,30 +4088,26 @@ static void dump_mips_specific_info(struct readelf *re) { struct section *s; - int i, options_found; + int i; - options_found = 0; s = NULL; for (i = 0; (size_t) i < re->shnum; i++) { s = &re->sl[i]; if (s->name != NULL && (!strcmp(s->name, ".MIPS.options") || (s->type == SHT_MIPS_OPTIONS))) { dump_mips_options(re, s); - options_found = 1; } } /* - * According to SGI mips64 spec, .reginfo should be ignored if - * .MIPS.options section is present. + * Dump .reginfo if present (although it will be ignored by an OS if a + * .MIPS.options section is present, according to SGI mips64 spec). */ - if (!options_found) { - for (i = 0; (size_t) i < re->shnum; i++) { - s = &re->sl[i]; - if (s->name != NULL && (!strcmp(s->name, ".reginfo") || - (s->type == SHT_MIPS_REGINFO))) - dump_mips_reginfo(re, s); - } + for (i = 0; (size_t) i < re->shnum; i++) { + s = &re->sl[i]; + if (s->name != NULL && (!strcmp(s->name, ".reginfo") || + (s->type == SHT_MIPS_REGINFO))) + dump_mips_reginfo(re, s); } } @@ -6196,9 +6203,7 @@ dump_dwarf_loclist(struct readelf *re) Dwarf_Half tag, version, pointer_size, off_size; Dwarf_Error de; struct loc_at *la; - int i, j, ret; - - printf("\nContents of section .debug_loc:\n"); + int i, j, ret, has_content; /* Search .debug_info section. */ while ((ret = dwarf_next_cu_header_b(re->dbg, NULL, &version, NULL, @@ -6215,7 +6220,7 @@ dump_dwarf_loclist(struct readelf *re) lowpc = 0; if (tag == DW_TAG_compile_unit) { if (dwarf_attrval_unsigned(die, DW_AT_low_pc, - &lowpc, &de) != DW_DLV_OK) + &lowpc, &de) != DW_DLV_OK) lowpc = 0; } @@ -6261,14 +6266,20 @@ dump_dwarf_loclist(struct readelf *re) if (TAILQ_EMPTY(&lalist)) return; - printf(" Offset Begin End Expression\n"); - + has_content = 0; TAILQ_FOREACH(la, &lalist, la_next) { - if (dwarf_loclist_n(la->la_at, &llbuf, &lcnt, &de) != + if ((ret = dwarf_loclist_n(la->la_at, &llbuf, &lcnt, &de)) != DW_DLV_OK) { - warnx("dwarf_loclist_n failed: %s", dwarf_errmsg(de)); + if (ret != DW_DLV_NO_ENTRY) + warnx("dwarf_loclist_n failed: %s", + dwarf_errmsg(de)); continue; } + if (!has_content) { + has_content = 1; + printf("\nContents of section .debug_loc:\n"); + printf(" Offset Begin End Expression\n"); + } set_cu_context(re, la->la_cu_psize, la->la_cu_osize, la->la_cu_ver); for (i = 0; i < lcnt; i++) { @@ -6303,6 +6314,9 @@ dump_dwarf_loclist(struct readelf *re) } dwarf_dealloc(re->dbg, llbuf, DW_DLA_LIST); } + + if (!has_content) + printf("\nSection '.debug_loc' has no debugging data.\n"); } /* @@ -6535,13 +6549,14 @@ load_sections(struct readelf *re) } if ((name = elf_strptr(re->elf, shstrndx, sh.sh_name)) == NULL) { (void) elf_errno(); - name = "ERROR"; + name = ""; } if ((ndx = elf_ndxscn(scn)) == SHN_UNDEF) { - if ((elferr = elf_errno()) != 0) + if ((elferr = elf_errno()) != 0) { warnx("elf_ndxscn failed: %s", elf_errmsg(elferr)); - continue; + continue; + } } if (ndx >= re->shnum) { warnx("section index of '%s' out of range", name); @@ -6649,8 +6664,9 @@ dump_elf(struct readelf *re) static void dump_dwarf(struct readelf *re) { - int error; + struct loc_at *la, *_la; Dwarf_Error de; + int error; if (dwarf_elf_init(re->elf, DW_DLC_READ, NULL, NULL, &re->dbg, &de)) { if ((error = dwarf_errno(de)) != DW_DLE_DEBUG_INFO_NULL) @@ -6686,6 +6702,11 @@ dump_dwarf(struct readelf *re) if (re->dop & DW_O) dump_dwarf_loclist(re); + TAILQ_FOREACH_SAFE(la, &lalist, la_next, _la) { + TAILQ_REMOVE(&lalist, la, la_next); + free(la); + } + dwarf_finish(re->dbg, &de); } diff --git a/strings/strings.c b/strings/strings.c index 8de29ca7d25b..fbc800109856 100644 --- a/strings/strings.c +++ b/strings/strings.c @@ -46,13 +46,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: strings.c 3446 2016-05-03 01:31:17Z emaste $"); - -enum return_code { - RETURN_OK, - RETURN_NOINPUT, - RETURN_SOFTWARE -}; +ELFTC_VCSID("$Id: strings.c 3498 2016-10-26 19:25:13Z emaste $"); enum radix_style { RADIX_DECIMAL, @@ -107,7 +101,7 @@ main(int argc, char **argv) { int ch, rc; - rc = RETURN_OK; + rc = 0; min_len = 0; encoding_size = 1; if (elf_version(EV_CURRENT) == EV_NONE) @@ -197,7 +191,8 @@ main(int argc, char **argv) if (!*argv) rc = handle_file("{standard input}"); else while (*argv) { - rc = handle_file(*argv); + if (handle_file(*argv) != 0) + rc = 1; argv++; } return (rc); @@ -209,11 +204,11 @@ handle_file(const char *name) int fd, rt; if (name == NULL) - return (RETURN_NOINPUT); + return (1); if (strcmp("{standard input}", name) != 0) { if (freopen(name, "rb", stdin) == NULL) { warnx("'%s': %s", name, strerror(errno)); - return (RETURN_NOINPUT); + return (1); } } else { return (find_strings(name, (off_t)0, (off_t)0)); @@ -221,7 +216,7 @@ handle_file(const char *name) fd = fileno(stdin); if (fd < 0) - return (RETURN_NOINPUT); + return (1); rt = handle_elf(name, fd); return (rt); } @@ -239,7 +234,7 @@ handle_binary(const char *name, int fd) (void) lseek(fd, (off_t)0, SEEK_SET); if (!fstat(fd, &buf)) return (find_strings(name, (off_t)0, buf.st_size)); - return (RETURN_SOFTWARE); + return (1); } /* @@ -257,7 +252,7 @@ handle_elf(const char *name, int fd) Elf_Scn *scn; int rc; - rc = RETURN_OK; + rc = 0; /* If entire file is chosen, treat it as a binary file */ if (entire_file) return (handle_binary(name, fd)); @@ -272,7 +267,7 @@ handle_elf(const char *name, int fd) if (gelf_getehdr(elf, &elfhdr) == NULL) { (void) elf_end(elf); warnx("%s: ELF file could not be processed", name); - return (RETURN_SOFTWARE); + return (1); } if (elfhdr.e_shnum == 0 && elfhdr.e_type == ET_CORE) { @@ -352,7 +347,7 @@ find_strings(const char *name, off_t offset, off_t size) if ((obuf = (char*)calloc(1, min_len + 1)) == NULL) { (void) fprintf(stderr, "Unable to allocate memory: %s\n", strerror(errno)); - return (RETURN_SOFTWARE); + return (1); } (void) fseeko(stdin, offset, SEEK_SET); @@ -426,7 +421,7 @@ find_strings(const char *name, off_t offset, off_t size) } _exit1: free(obuf); - return (RETURN_OK); + return (0); } #define USAGE_MESSAGE "\ diff --git a/test/ar/plugin/os.FreeBSD.mk b/test/ar/plugin/os.FreeBSD.mk new file mode 100644 index 000000000000..c29af70518a9 --- /dev/null +++ b/test/ar/plugin/os.FreeBSD.mk @@ -0,0 +1,2 @@ +DPADD+= ${LIBBZ2} +LDADD+= -lbz2 diff --git a/test/cxxfilt/tet_scen b/test/cxxfilt/tet_scen index 2f920e30ae4a..ec503cd8389d 100644 --- a/test/cxxfilt/tet_scen +++ b/test/cxxfilt/tet_scen @@ -3,9 +3,15 @@ all "Starting Test Suite" ^misc + ^regression "Complete Test Suite" misc - "Starting noarg Test" + "Starting misc Test" /ts/misc/tc - "Complete noarg Test" + "Complete misc Test" + +regression + "Starting regression Test" + /ts/regression/tc + "Complete regression Test" diff --git a/test/cxxfilt/ts/Makefile b/test/cxxfilt/ts/Makefile index 0dff69204380..9e2f728033c4 100644 --- a/test/cxxfilt/ts/Makefile +++ b/test/cxxfilt/ts/Makefile @@ -3,5 +3,6 @@ TOP= ../../.. SUBDIR+= misc +SUBDIR+= regression -.include "${TOP}/mk/elftoolchain.subdir.mk" \ No newline at end of file +.include "${TOP}/mk/elftoolchain.subdir.mk" diff --git a/test/cxxfilt/ts/regression/Makefile b/test/cxxfilt/ts/regression/Makefile new file mode 100644 index 000000000000..ecc228b09b30 --- /dev/null +++ b/test/cxxfilt/ts/regression/Makefile @@ -0,0 +1,5 @@ +# $Id$ + +TOP= ../../../.. + +.include "../common/ts.mk" diff --git a/test/cxxfilt/ts/regression/tclist b/test/cxxfilt/ts/regression/tclist new file mode 100644 index 000000000000..e10ea4396f51 --- /dev/null +++ b/test/cxxfilt/ts/regression/tclist @@ -0,0 +1,34 @@ +# ticket 481, TLS wrappers +"_ZTWL20PrettyStackTraceHead", "TLS wrapper function for PrettyStackTraceHead" + +# ticket 488, trailing E +"_ZN1fILi4EEE", "f<4>" + +# ticket 489, handle Dv (__vector) +"_Z22__gen_ocl_write_imagef11ocl_image2dDv2_iDv4_f", "__gen_ocl_write_imagef(ocl_image2d, int __vector(2), float __vector(4))" +"_Z23__gen_ocl_write_imageui16ocl_image2darrayDv3_iDv4_j", "__gen_ocl_write_imageui(ocl_image2darray, int __vector(3), unsigned int __vector(4))" +"_Z1fDv2_i", "f(int __vector(2))" + +# ticket 491, omit "void" +"_Z1fv", "f()" +"_Z1fPv", "f(void*)" +"_Z1fiv", "f(int, void)" +"_Z1fvi", "f(void, int)" + +# ticket 508, demangler failure +"_ZN8TaskPool11AddTaskImplEONSt3__18functionIFvvEEE", "TaskPool::AddTaskImpl(std::__1::function&&)" + +# ticket 530, assertion failure +"_ZNSp16invalidOargumentC1ERKSs", "invalidOargument::invalidOargument(std::basic_string, std::allocator > const&)" + +# ticket 531, assertion failure +"____new_strtold_internal", "____new_strtold_internal" + +# ticket 537, demangler fails on a symbol from GNU gold +"_ZN4gold15relocate_relocsILi64ELb1ENS_22Default_classify_relocILi4ELi64ELb1EEEEEvPKNS_13Relocate_infoIXT_EXT0_EEEPKhmPNS_14Output_sectionEN6elfcpp9Elf_typesIXT_EE7Elf_OffEPhNSD_8Elf_AddrEmSF_m", "void gold::relocate_relocs<64, true, gold::Default_classify_reloc<4, 64, true> >(gold::Relocate_info<64, true> const*, unsigned char const*, unsigned long, gold::Output_section*, elfcpp::Elf_types<64>::Elf_Off, unsigned char*, elfcpp::Elf_types<64>::Elf_Addr, unsigned long, unsigned char*, unsigned long)" + +# ticket 538, demangler uses incorrect back-ref +"_ZN1f1gEP1hNS0_1iE", "f::g(h*, h::i)" + +# ticket 539, demangler does not demangle lambdas +"_ZZN9libunwind17LocalAddressSpace18findUnwindSectionsEjRNS_18UnwindInfoSectionsEENUlP12dl_phdr_infojPvE_8__invokeES4_jS5_", "libunwind::LocalAddressSpace::findUnwindSections(unsigned int, libunwind::UnwindInfoSections&)::{lambda(dl_phdr_info*, unsigned int, void*)#1}::__invoke(dl_phdr_info*, unsigned int, void*)"