From owner-svn-src-projects@FreeBSD.ORG Sat May 7 23:34:14 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE7291065672; Sat, 7 May 2011 23:34:14 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC70B8FC12; Sat, 7 May 2011 23:34:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p47NYEoE019604; Sat, 7 May 2011 23:34:14 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p47NYEEZ019588; Sat, 7 May 2011 23:34:14 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201105072334.p47NYEEZ019588@svn.freebsd.org> From: Attilio Rao Date: Sat, 7 May 2011 23:34:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221613 - in projects/largeSMP: bin/sh contrib/top lib/libdwarf lib/libelf share/man/man5 share/mk sys/boot/common sys/cam/scsi sys/dev/ath/ath_hal sys/dev/ath/ath_hal/ar5416 sys/dev/at... X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 May 2011 23:34:14 -0000 Author: attilio Date: Sat May 7 23:34:14 2011 New Revision: 221613 URL: http://svn.freebsd.org/changeset/base/221613 Log: MFC Added: projects/largeSMP/lib/libdwarf/dwarf_func.c - copied unchanged from r221612, head/lib/libdwarf/dwarf_func.c projects/largeSMP/tools/regression/bin/sh/expansion/length7.0 - copied unchanged from r221612, head/tools/regression/bin/sh/expansion/length7.0 projects/largeSMP/tools/regression/bin/sh/expansion/length8.0 - copied unchanged from r221612, head/tools/regression/bin/sh/expansion/length8.0 Modified: projects/largeSMP/bin/sh/expand.c projects/largeSMP/bin/sh/main.c projects/largeSMP/bin/sh/var.c projects/largeSMP/bin/sh/var.h projects/largeSMP/lib/libdwarf/Makefile projects/largeSMP/lib/libdwarf/_libdwarf.h projects/largeSMP/lib/libdwarf/dwarf_init.c projects/largeSMP/lib/libdwarf/libdwarf.h projects/largeSMP/lib/libelf/Makefile projects/largeSMP/lib/libelf/elf_data.c projects/largeSMP/lib/libelf/elf_getdata.3 projects/largeSMP/lib/libelf/libelf_data.c projects/largeSMP/share/man/man5/ar.5 projects/largeSMP/sys/boot/common/interp.c projects/largeSMP/sys/cam/scsi/scsi_cd.c projects/largeSMP/sys/dev/ath/ath_hal/ah.c projects/largeSMP/sys/dev/ath/ath_hal/ah.h projects/largeSMP/sys/dev/ath/ath_hal/ah_debug.h projects/largeSMP/sys/dev/ath/ath_hal/ah_internal.h projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416desc.h projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416phy.h projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416reg.h projects/largeSMP/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c projects/largeSMP/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9280_olc.c projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c projects/largeSMP/sys/dev/usb/usbdevs projects/largeSMP/sys/dev/xl/if_xl.c projects/largeSMP/sys/dev/xl/if_xlreg.h projects/largeSMP/sys/i386/i386/machdep.c projects/largeSMP/sys/ia64/ia64/pmap.c projects/largeSMP/sys/kern/kern_environment.c projects/largeSMP/sys/sys/elf_common.h projects/largeSMP/usr.sbin/usbdump/usbdump.c Directory Properties: projects/largeSMP/ (props changed) projects/largeSMP/cddl/contrib/opensolaris/ (props changed) projects/largeSMP/contrib/bind9/ (props changed) projects/largeSMP/contrib/binutils/ (props changed) projects/largeSMP/contrib/bzip2/ (props changed) projects/largeSMP/contrib/dialog/ (props changed) projects/largeSMP/contrib/ee/ (props changed) projects/largeSMP/contrib/expat/ (props changed) projects/largeSMP/contrib/file/ (props changed) projects/largeSMP/contrib/gcc/ (props changed) projects/largeSMP/contrib/gdb/ (props changed) projects/largeSMP/contrib/gdtoa/ (props changed) projects/largeSMP/contrib/gnu-sort/ (props changed) projects/largeSMP/contrib/groff/ (props changed) projects/largeSMP/contrib/less/ (props changed) projects/largeSMP/contrib/libpcap/ (props changed) projects/largeSMP/contrib/libstdc++/ (props changed) projects/largeSMP/contrib/llvm/ (props changed) projects/largeSMP/contrib/llvm/tools/clang/ (props changed) projects/largeSMP/contrib/ncurses/ (props changed) projects/largeSMP/contrib/netcat/ (props changed) projects/largeSMP/contrib/ntp/ (props changed) projects/largeSMP/contrib/one-true-awk/ (props changed) projects/largeSMP/contrib/openbsm/ (props changed) projects/largeSMP/contrib/openpam/ (props changed) projects/largeSMP/contrib/pf/ (props changed) projects/largeSMP/contrib/sendmail/ (props changed) projects/largeSMP/contrib/tcpdump/ (props changed) projects/largeSMP/contrib/tcsh/ (props changed) projects/largeSMP/contrib/top/ (props changed) projects/largeSMP/contrib/top/install-sh (props changed) projects/largeSMP/contrib/tzcode/stdtime/ (props changed) projects/largeSMP/contrib/tzcode/zic/ (props changed) projects/largeSMP/contrib/tzdata/ (props changed) projects/largeSMP/contrib/wpa/ (props changed) projects/largeSMP/contrib/xz/ (props changed) projects/largeSMP/crypto/openssh/ (props changed) projects/largeSMP/crypto/openssl/ (props changed) projects/largeSMP/gnu/lib/ (props changed) projects/largeSMP/gnu/usr.bin/binutils/ (props changed) projects/largeSMP/gnu/usr.bin/cc/cc_tools/ (props changed) projects/largeSMP/gnu/usr.bin/gdb/ (props changed) projects/largeSMP/lib/libc/ (props changed) projects/largeSMP/lib/libc/stdtime/ (props changed) projects/largeSMP/lib/libutil/ (props changed) projects/largeSMP/lib/libz/ (props changed) projects/largeSMP/sbin/ (props changed) projects/largeSMP/sbin/ipfw/ (props changed) projects/largeSMP/share/mk/bsd.arch.inc.mk (props changed) projects/largeSMP/share/zoneinfo/ (props changed) projects/largeSMP/sys/ (props changed) projects/largeSMP/sys/amd64/include/xen/ (props changed) projects/largeSMP/sys/boot/ (props changed) projects/largeSMP/sys/boot/i386/efi/ (props changed) projects/largeSMP/sys/boot/ia64/efi/ (props changed) projects/largeSMP/sys/boot/ia64/ski/ (props changed) projects/largeSMP/sys/boot/powerpc/boot1.chrp/ (props changed) projects/largeSMP/sys/boot/powerpc/ofw/ (props changed) projects/largeSMP/sys/cddl/contrib/opensolaris/ (props changed) projects/largeSMP/sys/conf/ (props changed) projects/largeSMP/sys/contrib/dev/acpica/ (props changed) projects/largeSMP/sys/contrib/octeon-sdk/ (props changed) projects/largeSMP/sys/contrib/pf/ (props changed) projects/largeSMP/sys/contrib/x86emu/ (props changed) projects/largeSMP/usr.bin/calendar/ (props changed) projects/largeSMP/usr.bin/csup/ (props changed) projects/largeSMP/usr.bin/procstat/ (props changed) projects/largeSMP/usr.sbin/ndiscvt/ (props changed) projects/largeSMP/usr.sbin/zic/ (props changed) Modified: projects/largeSMP/bin/sh/expand.c ============================================================================== --- projects/largeSMP/bin/sh/expand.c Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/bin/sh/expand.c Sat May 7 23:34:14 2011 (r221613) @@ -665,6 +665,7 @@ evalvar(char *p, int flag) int special; int startloc; int varlen; + int varlenb; int easy; int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR); @@ -712,8 +713,15 @@ again: /* jump here after setting a vari if (special) { varvalue(var, varflags & VSQUOTE, subtype, flag); if (subtype == VSLENGTH) { - varlen = expdest - stackblock() - startloc; - STADJUST(-varlen, expdest); + varlenb = expdest - stackblock() - startloc; + varlen = varlenb; + if (localeisutf8) { + val = stackblock() + startloc; + for (;val != expdest; val++) + if ((*val & 0xC0) == 0x80) + varlen--; + } + STADJUST(-varlenb, expdest); } } else { char const *syntax = (varflags & VSQUOTE) ? DQSYNTAX @@ -721,7 +729,9 @@ again: /* jump here after setting a vari if (subtype == VSLENGTH) { for (;*val; val++) - varlen++; + if (!localeisutf8 || + (*val & 0xC0) != 0x80) + varlen++; } else { if (quotes) Modified: projects/largeSMP/bin/sh/main.c ============================================================================== --- projects/largeSMP/bin/sh/main.c Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/bin/sh/main.c Sat May 7 23:34:14 2011 (r221613) @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); int rootpid; int rootshell; struct jmploc main_handler; +int localeisutf8; static void read_profile(const char *); static char *find_dot_file(char *); @@ -96,6 +97,7 @@ main(int argc, char *argv[]) char *shinit; (void) setlocale(LC_ALL, ""); + updatecharset(); state = 0; if (setjmp(main_handler.loc)) { switch (exception) { Modified: projects/largeSMP/bin/sh/var.c ============================================================================== --- projects/largeSMP/bin/sh/var.c Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/bin/sh/var.c Sat May 7 23:34:14 2011 (r221613) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include "shell.h" #include "output.h" @@ -361,6 +362,7 @@ setvareq(char *s, int flags) if ((vp->flags & VEXPORT) && localevar(s)) { change_env(s, 1); (void) setlocale(LC_ALL, ""); + updatecharset(); } INTON; return; @@ -379,6 +381,7 @@ setvareq(char *s, int flags) if ((vp->flags & VEXPORT) && localevar(s)) { change_env(s, 1); (void) setlocale(LC_ALL, ""); + updatecharset(); } INTON; } @@ -480,6 +483,7 @@ bltinsetlocale(void) if (loc != NULL) { setlocale(LC_ALL, loc); INTON; + updatecharset(); return; } locdef = bltinlookup("LANG", 0); @@ -491,6 +495,7 @@ bltinsetlocale(void) setlocale(locale_categories[i], loc); } INTON; + updatecharset(); } /* @@ -505,12 +510,24 @@ bltinunsetlocale(void) for (lp = cmdenviron ; lp ; lp = lp->next) { if (localevar(lp->text)) { setlocale(LC_ALL, ""); + updatecharset(); return; } } INTON; } +/* + * Update the localeisutf8 flag. + */ +void +updatecharset(void) +{ + char *charset; + + charset = nl_langinfo(CODESET); + localeisutf8 = !strcmp(charset, "UTF-8"); +} /* * Generate a list of exported variables. This routine is used to construct @@ -656,6 +673,7 @@ exportcmd(int argc, char **argv) if ((vp->flags & VEXPORT) && localevar(vp->text)) { change_env(vp->text, 1); (void) setlocale(LC_ALL, ""); + updatecharset(); } goto found; } @@ -850,6 +868,7 @@ unsetvar(const char *s) if ((vp->flags & VEXPORT) && localevar(vp->text)) { change_env(s, 0); setlocale(LC_ALL, ""); + updatecharset(); } vp->flags &= ~VEXPORT; vp->flags |= VUNSET; Modified: projects/largeSMP/bin/sh/var.h ============================================================================== --- projects/largeSMP/bin/sh/var.h Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/bin/sh/var.h Sat May 7 23:34:14 2011 (r221613) @@ -81,6 +81,8 @@ extern struct var vhistsize; extern struct var vterm; #endif +extern int localeisutf8; + /* * The following macros access the values of the above variables. * They have to skip over the name. They return the null string @@ -112,6 +114,7 @@ char *lookupvar(const char *); char *bltinlookup(const char *, int); void bltinsetlocale(void); void bltinunsetlocale(void); +void updatecharset(void); char **environment(void); int showvarscmd(int, char **); int exportcmd(int, char **); Modified: projects/largeSMP/lib/libdwarf/Makefile ============================================================================== --- projects/largeSMP/lib/libdwarf/Makefile Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libdwarf/Makefile Sat May 7 23:34:14 2011 (r221613) @@ -14,6 +14,7 @@ SRCS= \ dwarf_errno.c \ dwarf_finish.c \ dwarf_form.c \ + dwarf_func.c \ dwarf_init.c \ dwarf_loc.c Modified: projects/largeSMP/lib/libdwarf/_libdwarf.h ============================================================================== --- projects/largeSMP/lib/libdwarf/_libdwarf.h Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libdwarf/_libdwarf.h Sat May 7 23:34:14 2011 (r221613) @@ -163,6 +163,37 @@ struct _Dwarf_Debug { dbg_cu; /* List of compilation units. */ Dwarf_CU dbg_cu_current; /* Ptr to the current compilation unit. */ + + STAILQ_HEAD(, _Dwarf_Func) dbg_func; /* List of functions */ +}; + +struct _Dwarf_Func { + Dwarf_Die func_die; + const char *func_name; + Dwarf_Addr func_low_pc; + Dwarf_Addr func_high_pc; + int func_is_inlined; + /* inlined instance */ + STAILQ_HEAD(, _Dwarf_Inlined_Func) func_inlined_instances; + STAILQ_ENTRY(_Dwarf_Func) func_next; }; +struct _Dwarf_Inlined_Func { + struct _Dwarf_Func *ifunc_origin; + Dwarf_Die ifunc_abstract; + Dwarf_Die ifunc_concrete; + Dwarf_Addr ifunc_low_pc; + Dwarf_Addr ifunc_high_pc; + STAILQ_ENTRY(_Dwarf_Inlined_Func) ifunc_next; +}; + +void dwarf_build_function_table(Dwarf_Debug dbg); + +#ifdef DWARF_DEBUG +#include +#define DWARF_ASSERT(x) assert(x) +#else +#define DWARF_ASSERT(x) +#endif + #endif /* !__LIBDWARF_H_ */ Copied: projects/largeSMP/lib/libdwarf/dwarf_func.c (from r221612, head/lib/libdwarf/dwarf_func.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/largeSMP/lib/libdwarf/dwarf_func.c Sat May 7 23:34:14 2011 (r221613, copy of r221612, head/lib/libdwarf/dwarf_func.c) @@ -0,0 +1,227 @@ +/*- + * Copyright (c) 2008-2009, 2011, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * JNPR: dwarf_func.c 336441 2009-10-17 09:19:54Z deo + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include <_libdwarf.h> + +static void +dwarf_add_function(Dwarf_Debug dbg, Dwarf_Func func) +{ + + STAILQ_INSERT_TAIL(&dbg->dbg_func, func, func_next); +} + +int +dwarf_function_get_addr_range(Dwarf_Func f, Dwarf_Addr *low_pc, + Dwarf_Addr *high_pc) +{ + + *low_pc = f->func_low_pc; + *high_pc = f->func_high_pc; + return 0; +} + +int +dwarf_inlined_function_get_addr_range(Dwarf_Inlined_Func f, Dwarf_Addr *low_pc, + Dwarf_Addr *high_pc) +{ + + *low_pc = f->ifunc_low_pc; + *high_pc = f->ifunc_high_pc; + return 0; +} + +int +dwarf_function_is_inlined(Dwarf_Func f) +{ + + if (f->func_is_inlined == DW_INL_inlined || + f->func_is_inlined == DW_INL_declared_inlined) + return 1; + else + return 0; +} + +Dwarf_Func +dwarf_find_function_by_name(Dwarf_Debug dbg, const char *name) +{ + /* XXX: replace with a fast version */ + + Dwarf_Func func; + STAILQ_FOREACH(func, &dbg->dbg_func, func_next) { + if (strcmp(name, func->func_name) == 0) + return func; + } + return NULL; +} + +Dwarf_Func +dwarf_find_function_by_offset(Dwarf_Debug dbg, Dwarf_Off off) +{ + + Dwarf_Func func; + Dwarf_Die die; + /* printf("look for %llx\n", off); */ + STAILQ_FOREACH(func, &dbg->dbg_func, func_next) { + die = func->func_die; + if ((off_t)die->die_offset == off) { + return func; + } + } + return NULL; +} + +void +dwarf_build_function_table(Dwarf_Debug dbg) +{ + Dwarf_CU cu; + Dwarf_AttrValue av; + Dwarf_Die die, origin_die; + Dwarf_Func func, origin_func; + Dwarf_Inlined_Func ifunc; + unsigned long long offset; + const char *name; + Dwarf_Error error; + + /* + * find out all the functions + */ + STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) { + STAILQ_FOREACH(die, &cu->cu_die, die_next) { + if (die->die_a->a_tag == DW_TAG_subprogram) { + /* + * Some function has multiple entries, i.e. + * if a function is inlined, it has many + * abstract/concrete instances, the abstract + * instances are with DW_TAG_subprogram. + */ + dwarf_attrval_string(die, DW_AT_name, &name, + &error); + func = dwarf_find_function_by_name(dbg, name); + if (func == NULL) { + func = malloc( + sizeof(struct _Dwarf_Func)); + DWARF_ASSERT(func); + + func->func_die = die; + func->func_name = name; + STAILQ_INIT( + &func->func_inlined_instances); + + dwarf_add_function(dbg, func); + STAILQ_FOREACH(av, &die->die_attrval, + av_next) { + switch (av->av_attrib) { + case DW_AT_low_pc: + func->func_low_pc = + av->u[0].u64; + break; + case DW_AT_high_pc: + func->func_high_pc = + av->u[0].u64; + break; + case DW_AT_inline: + func->func_is_inlined = + av->u[0].u64; + break; + } + } + } + } + } + } + + /* + * Now check the concrete inlined instances. + */ + STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) { + STAILQ_FOREACH(die, &cu->cu_die, die_next) { + if (die->die_a->a_tag == DW_TAG_inlined_subroutine) { + ifunc = malloc( + sizeof(struct _Dwarf_Inlined_Func)); + DWARF_ASSERT(ifunc); + STAILQ_FOREACH(av, &die->die_attrval, av_next) { + switch (av->av_attrib) { + case DW_AT_abstract_origin: + offset = av->u[0].u64 + + die->die_cu->cu_offset; + origin_die = dwarf_die_find( + die, offset); + DWARF_ASSERT(origin_die != 0); + + /* + * the abstract origin must + * have been merged with + * another die + */ + dwarf_attrval_string( + origin_die, DW_AT_name, + &name, &error); + origin_func = + dwarf_find_function_by_name + (dbg, name); + DWARF_ASSERT(origin_func != 0); + + STAILQ_INSERT_TAIL( + &origin_func-> + func_inlined_instances, + ifunc, ifunc_next); + + break; + case DW_AT_low_pc: + ifunc->ifunc_low_pc = + av->u[0].u64; + break; + case DW_AT_high_pc: + ifunc->ifunc_high_pc = + av->u[0].u64; + break; + } + } + } + } + } +} + +void +dwarf_function_iterate_inlined_instance(Dwarf_Func func, + Dwarf_Inlined_Callback f, void *data) +{ + Dwarf_Inlined_Func ifunc; + + if (!dwarf_function_is_inlined(func)) + return; + STAILQ_FOREACH(ifunc, &func->func_inlined_instances, ifunc_next) { + f(ifunc, data); + } +} Modified: projects/largeSMP/lib/libdwarf/dwarf_init.c ============================================================================== --- projects/largeSMP/lib/libdwarf/dwarf_init.c Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libdwarf/dwarf_init.c Sat May 7 23:34:14 2011 (r221613) @@ -578,6 +578,9 @@ dwarf_init_info(Dwarf_Debug dbg, Dwarf_E offset = next_offset; } + /* Build the function table. */ + dwarf_build_function_table(dbg); + return ret; } @@ -686,6 +689,7 @@ dwarf_elf_init(Elf *elf, int mode, Dwarf dbg->dbg_mode = mode; STAILQ_INIT(&dbg->dbg_cu); + STAILQ_INIT(&dbg->dbg_func); *ret_dbg = dbg; Modified: projects/largeSMP/lib/libdwarf/libdwarf.h ============================================================================== --- projects/largeSMP/lib/libdwarf/libdwarf.h Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libdwarf/libdwarf.h Sat May 7 23:34:14 2011 (r221613) @@ -51,6 +51,7 @@ typedef struct _Dwarf_Debug *Dwarf_Debug typedef struct _Dwarf_Die *Dwarf_Die; typedef struct _Dwarf_Fde *Dwarf_Fde; typedef struct _Dwarf_Func *Dwarf_Func; +typedef struct _Dwarf_Inlined_Func *Dwarf_Inlined_Func; typedef struct _Dwarf_Global *Dwarf_Global; typedef struct _Dwarf_Line *Dwarf_Line; typedef struct _Dwarf_Type *Dwarf_Type; @@ -71,6 +72,9 @@ typedef struct { Dwarf_Loc *ld_s; } Dwarf_Locdesc; +/* receiver function for dwarf_function_iterate_inlined_instance() API */ +typedef void (*Dwarf_Inlined_Callback)(Dwarf_Inlined_Func, void *); + /* * Error numbers which are specific to this implementation. */ @@ -157,6 +161,16 @@ void dwarf_dump_strtab(Dwarf_Debug); void dwarf_dump_symtab(Dwarf_Debug); void dwarf_dump_raw(Dwarf_Debug); void dwarf_dump_tree(Dwarf_Debug); +Dwarf_Func dwarf_find_function_by_offset(Dwarf_Debug dbg, Dwarf_Off off); +Dwarf_Func dwarf_find_function_by_name(Dwarf_Debug dbg, const char *name); +int dwarf_function_get_addr_range(Dwarf_Func f, + Dwarf_Addr *low_pc, Dwarf_Addr *high_pc); +int dwarf_function_is_inlined(Dwarf_Func f); +void dwarf_function_iterate_inlined_instance(Dwarf_Func func, + Dwarf_Inlined_Callback f, void *data); +int dwarf_inlined_function_get_addr_range(Dwarf_Inlined_Func f, + Dwarf_Addr *low_pc, Dwarf_Addr *high_pc); + __END_DECLS #endif /* !_LIBDWARF_H_ */ Modified: projects/largeSMP/lib/libelf/Makefile ============================================================================== --- projects/largeSMP/lib/libelf/Makefile Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libelf/Makefile Sat May 7 23:34:14 2011 (r221613) @@ -57,7 +57,7 @@ INCS= libelf.h gelf.h GENSRCS= libelf_fsize.c libelf_msize.c libelf_convert.c CLEANFILES= ${GENSRCS} -CFLAGS+= -I. -I${.CURDIR} +CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../sys SHLIB_MAJOR= 1 Modified: projects/largeSMP/lib/libelf/elf_data.c ============================================================================== --- projects/largeSMP/lib/libelf/elf_data.c Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libelf/elf_data.c Sat May 7 23:34:14 2011 (r221613) @@ -225,7 +225,8 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d->d_buf = sh_type == SHT_NOBITS ? NULL : e->e_rawfile + sh_offset; + d->d_buf = (sh_type == SHT_NOBITS || sh_size == 0) ? NULL : + e->e_rawfile + sh_offset; d->d_off = 0; d->d_align = sh_align; d->d_size = sh_size; Modified: projects/largeSMP/lib/libelf/elf_getdata.3 ============================================================================== --- projects/largeSMP/lib/libelf/elf_getdata.3 Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libelf/elf_getdata.3 Sat May 7 23:34:14 2011 (r221613) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. +.\" Copyright (c) 2006,2008,2010-2011 Joseph Koshy. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 30, 2010 +.Dd January 26, 2011 .Dt ELF_GETDATA 3 .Os .Sh NAME @@ -142,9 +142,10 @@ always returns .Vt Elf_Data structures of type .Dv ELF_T_BYTE . -.Ss Special handling of SHT_NOBITS sections +.Ss Special handling of zero-sized and SHT_NOBITS sections For sections of type -.Dv SHT_NOBITS , +.Dv SHT_NOBITS, +and for zero-sized sections, the functions .Fn elf_getdata and Modified: projects/largeSMP/lib/libelf/libelf_data.c ============================================================================== --- projects/largeSMP/lib/libelf/libelf_data.c Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/lib/libelf/libelf_data.c Sat May 7 23:34:14 2011 (r221613) @@ -84,6 +84,8 @@ _libelf_xlate_shtype(uint32_t sht) case SHT_SUNW_dof: return (ELF_T_BYTE); #endif + case SHT_MIPS_DWARF: + /* FALLTHROUGH */ case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */ return (ELF_T_BYTE); default: Modified: projects/largeSMP/share/man/man5/ar.5 ============================================================================== --- projects/largeSMP/share/man/man5/ar.5 Sat May 7 22:20:01 2011 (r221612) +++ projects/largeSMP/share/man/man5/ar.5 Sat May 7 23:34:14 2011 (r221613) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2007 Joseph Koshy. All rights reserved. +.\" Copyright (c) 2010 Joseph Koshy. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -9,226 +9,319 @@ .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" -.\" This software is provided by Joseph Koshy ``as is'' and -.\" any express or implied warranties, including, but not limited to, the -.\" implied warranties of merchantability and fitness for a particular purpose -.\" are disclaimed. in no event shall Joseph Koshy be liable -.\" for any direct, indirect, incidental, special, exemplary, or consequential -.\" damages (including, but not limited to, procurement of substitute goods -.\" or services; loss of use, data, or profits; or business interruption) -.\" however caused and on any theory of liability, whether in contract, strict -.\" liability, or tort (including negligence or otherwise) arising in any way -.\" out of the use of this software, even if advised of the possibility of -.\" such damage. +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd September 7, 2007 -.Dt AR 5 +.Dd November 28, 2010 .Os +.Dt AR 5 .Sh NAME .Nm ar -.Nd format of archives managed by ar(1) and ranlib(1) +.Nd archive file format for +.Xr ar 1 +and +.Xr ranlib 1 .Sh SYNOPSIS .In ar.h .Sh DESCRIPTION -An archive managed by the +.Xr ar 1 +archives are created and managed by the .Xr ar 1 and .Xr ranlib 1 -utilities is a single file that stores the individual members of the -archive along with metadata for each member. -There are two major variants of the +utilities. +These archives are typically used during program development to +hold libraries of program objects. +An +.Xr ar 1 +archive is contained in a single operating system file. +.Pp +This manual page documents two variants of the .Xr ar 1 -archive format, the BSD variant and the SVR4/GNU variant. -Both variants are described by this manual page. +archive format: the BSD archive format, and the SVR4/GNU archive +format. .Pp -The header file +In both variants the archive file starts with an identifying byte +sequence of the seven ASCII characters +.Sq Li "!" +followed by a ASCII linefeed character +.Po +see the constant +.Dq ARMAG +in the header file .In ar.h -defines constants and structures used to describe the layout -of these archives. -.Ss Archive Layout -.Xr ar 1 -archives start with a string of magic bytes -.Qq !\en -(constant -.Dv ARMAG -in header -.In ar.h ) . -The content of the archive follows the magic bytes. -Each member stored in the archive is preceded by a fixed size -archive header that stores file permissions, last modification -time, the owner, and the group of the archived file. -.Pp -Archive headers start at an even byte offset in the archive -file. -If the length of the preceding archive member was odd, then an extra -newline character -.Dq "\en" -is used as padding. -.Pp -The archive header comprises six fixed-size ASCII strings followed -by a two character trailer (see -.Vt "struct ar_hdr" -in header file -.In ar.h Ns ): -.Bd -literal -struct ar_hdr { - char ar_name[16]; /* name */ - char ar_date[12]; /* modification time */ - char ar_uid[6]; /* user id */ - char ar_gid[6]; /* group id */ - char ar_mode[8]; /* octal file permissions */ - char ar_size[10]; /* size in bytes */ - char ar_fmag[2]; /* consistency check */ -}; -.Ed -.Pp -Unused characters in the header are filled with space (ASCII 20H) -characters. -Each field of the header abuts the next without additional padding. -.Pp -The members of the archive header are as follows: -.Bl -tag -width "Va ar_name" -compact -.It Va ar_date -This field holds the decimal representation of the -modification time, in seconds since the epoch, of the archive -member. -.It Va ar_fmag -This trailer field holds the two characters -.Qq `\en -(constant -.Dv ARFMAG -defined in header file -.In ar.h Ns ), -and is used for consistency checks. -.It Va ar_gid -This field holds the decimal representation of the numeric -user id of the creator of the member. -.It Va ar_mode -This field holds octal representation of the file permissions -for the member. -.It Va ar_name -This field holds the name of an archive member. -The usage of this field depends on the format variant: -.Bl -tag -width "SVR4/GNU" -compact -.It BSD -In the BSD variant, names that are shorter than 16 characters and -without embedded spaces are stored directly in this field. -If a name has an embedded space, or if it is longer than 16 -characters, then the string -.Qq "#1/" -followed by the decimal representation of the length of the file name -is placed in this field. -The actual file name is stored immediately after the archive header. -The content of the archive member follows the file name. +.Pc . +.Pp +Archive members follow the initial identifying byte sequence. +Each archive member is prefixed by a fixed size header describing the +file attributes associated with the member. +.Ss "Archive Headers" +An archive header describes the file attributes for the archive member that +follows it. The -.Va ar_size -field of the header (see below) will then hold the sum of the size of -the file name and the size of the member. -.It SVR4/GNU -In the SVR4/GNU variant, names up to 15 characters in length are -stored directly in this field, and are terminated by a -.Qq / -(ASCII 2FH) character. -Names larger than 15 characters in length are stored in a special -archive string table member (see -.Sx "Archive String Table" -below), and the -.Va ar_name -field holds the string -.Qq "/" -followed by the decimal representation of the offset in the archive -string table of the actual name. +.Xr ar 5 +format only supports a limited number of attributes: the file name, +the file creation time stamp, the uid and gid of the creator, the file +mode and the file size. +.Pp +Archive headers are placed at an even byte offset in the archive file. +If the data for an archive member ends at an odd byte offset, then a +padding byte with value 0x0A is used to position the next archive +header on an even byte offset. +.Pp +An archive header comprises the following fixed sized fields: +.Bl -tag -width "Li ar_name" +.It Ar ar_name +(16 bytes) The file name of the archive member. +The format of this field varies between the BSD and SVR4/GNU formats and +is described in more detail in the section +.Sx "Representing File Names" +below. +.It Ar ar_date +(12 bytes) The file modification time for the member in seconds since the +epoch, encoded as a decimal number. +.It Ar ar_uid +(6 bytes) The uid associated with the archive member, encoded as a +decimal number. +.It Ar ar_gid +(6 bytes) The gid associated with the archive member, encoded as a +decimal number. +.It Ar ar_mode +(8 bytes) The file mode for the archive member, encoded as an octal +number. +.It Ar ar_size +(10 bytes) In the SVR4/GNU archive format this field holds the size in +bytes of the archive member, encoded as a decimal number. +In the BSD archive format, for short file names, this field +holds the size in bytes of the archive member, encoded as a decimal +number. +For long file names +.Po +see +.Sx "Representing File Names" +below +.Pc , +the field contains the combined size of the +archive member and its file name, encoded as a decimal number. +.It Ar ar_fmag +(2 bytes) This field holds 2 bytes with values 0x96 and 0x0A +respectively, marking the end of the header. +.El +.Pp +Unused bytes in the fields of an archive header are set to the value +0x20. +.Ss "Representing File Names" +The BSD and SVR4/GNU variants use different schemes for encoding file +names for members. +.Bl -tag -width "SVR4/GNU" +.It "BSD" +File names that are upto 16 bytes long and which do not contain +embedded spaces are stored directly in the +.Ar ar_name +field of the archive header. +File names that are either longer than 16 bytes or which contain +embedded spaces are stored immediately after the archive header +and the +.Ar ar_name +field of the archive header is set to the string +.Dq "#1/" +followed by a decimal representation of the number of bytes needed for +the file name. +In addition, the +.Ar ar_size +field of the archive header is set to the decimal representation of +the combined sizes of the archive member and the file name. +The file contents of the member follows the file name without further +padding. +.Pp +As an example, if the file name for a member was +.Dq "A B" +and its contents was the string +.Dq "C D" , +then the +.Ar ar_name +field of the header would contain +.Dq Li "#1/3" , +the +.Ar ar_size +field of the header would contain +.Dq Li 6 , +and the bytes immediately following the header would be 0x41, 0x20, +0x42, 0x43, 0x20 and 0x44 +.Po +ASCII +.Dq "A BC D" +.Pc . +.It "SVR4/GNU" +File names that are upto 15 characters long are stored directly in the +.Ar ar_name +field of the header, terminated by a +.Dq Li / +character. +.Pp +If the file name is larger than would fit in space for the +.Ar ar_name +field, then the actual file name is kept in the archive +string table +.Po +see +.Sx "Archive String Tables" +below +.Pc , +and the decimal offset of the file name in the string table is stored +in the +.Ar ar_name +field, prefixed by a +.Dq Li / +character. +.Pp +As an example, if the real file name has been stored at offset 768 in +the archive string table, the +.Ar ar_name +field of the header will contain the string +.Dq /768 . .El -.It Va ar_size -In the SVR4/GNU variant, this field holds the decimal representation -of actual size in bytes of the archived file. -In the BSD variant, for member names that use the -.Va ar_name -field directly, this field holds the decimal representation of the -actual size in bytes of the archived member. -For member names that use the extension mechanism described above, the -field will hold the sum of the sizes, in bytes, of the filename and the -archive member. -.It Va ar_uid -This field holds the decimal representation of the numeric -group id of the creator of the member. +.Ss "Special Archive Members" +The following archive members are special. +.Bl -tag -width indent +.It Dq Li / +In the SVR4/GNU variant of the archive format, the archive member with +name +.Dq Li / +denotes an archive symbol table. +If present, this member will be the very first member in the +archive. +.It Dq Li // +In the SVR4/GNU variant of the archive format, the archive member with +name +.Dq Li // +denotes the archive string table. +This special member is used to hold filenames that do not fit in the +file name field of the header +.Po +see +.Sx "Representing File Names" +above +.Pc . +If present, this member immediately follows the archive symbol table +if an archive symbol table is present, or is the first member otherwise. +.It Dq Li "__.SYMDEF" +This special member contains the archive symbol table in the BSD +variant of the archive format. +If present, this member will be the very first member in the +archive. .El -.Ss Archive Symbol Table -An archive may additionally contain an archive symbol table -used by the link editor, -.Xr ld 1 . -This symbol table has the member name -.Qq __.SYMDEF -in the BSD variant of the archive format, and the name -.Qq / -in the SVR4/GNU variant. +.Ss "Archive String Tables" +An archive string table is used in the SVR4/GNU archive format to hold +file names that are too large to fit into the constraints of the +.Ar ar_name +field of the archive header. +An archive string table contains a sequence of file names. +Each file name in the archive string table is terminated by the +byte sequence 0x2F, 0x0A +.Po +the ASCII string +.Dq "/\en" +.Pc . +No padding is used to separate adjacent file names. +.Ss "Archive Symbol Tables" +Archive symbol tables are used to speed up link editing by providing a +mapping between the program symbols defined in the archive +and the corresponding archive members. +Archive symbol tables are managed by the +.Xr ranlib 1 +utility. .Pp -The format of the symbol table depends on the format variant: -.Bl -tag -width "SVR4/GNU" -compact +The format of archive symbol tables is as follows: +.Bl -tag -width "SVR4/GNU" .It BSD -In the BSD variant, the symbol table has 4 parts encoded in -a machine dependent manner: -.Bl -enum -compact -.It -The first part is a binary value containing size in bytes of the -second part encoded as a C -.Dq long . -.It -The second part is a list of -.Vt struct ranlib -structures (see -.In ranlib.h Ns ). -Each ranlib structure describes one symbol and comprises of -two C -.Dq long -values. -The first -.Dq long -is a zero-based offset into the string table in the fourth part -for the symbol's name. -The second -.Dq long -is an offset from the beginning of the archive to the start -of the archive header for the member that defines the symbol. -.It -The third part is a binary value denoting the length of the -string table contained in the fourth part. -.It -The fourth part is a string table containing NUL-terminated -strings. +In the BSD archive format, the archive symbol table comprises +of two parts: a part containing an array of +.Vt "struct ranlib" +descriptors, followed by a part containing a symbol string table. +The sizes and layout of the structures that make up a BSD format +archive symbol table are machine dependent. +.Pp +The part containing +.Vt "struct ranlib" +descriptors begins with a field containing the size in bytes of the +array of +.Vt "struct ranlib" +descriptors encoded as a C +.Vt long +value. +.Pp +The array of +.Vt "struct ranlib" +descriptors follows the size field. +Each +.Vt "struct ranlib" +descriptor describes one symbol. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***