├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── README.md ├── libdwarf ├── BLD ├── BLDLIBDWARF ├── BLDLIBDWARFTAR ├── BLDTESTDIR ├── CLEANUP ├── CMakeLists.txt ├── CPTOPUBLIC ├── CREATINGARELEASE ├── DECOMPILER_README ├── Makefile.in ├── NEWS ├── README ├── REBLDLIBDWARF ├── SETUP_MASTER_TREE ├── SMBLDLIBDWARF ├── UPD.awk ├── UPDATEDWARFDUMPVERSION.sh ├── config.h.in ├── configure ├── configure.in ├── dwarfdump │ ├── CODINGSTYLE │ ├── COPYING │ ├── ChangeLog │ ├── ChangeLog2006 │ ├── ChangeLog2007 │ ├── ChangeLog2008 │ ├── ChangeLog2009 │ ├── ChangeLog2010 │ ├── ChangeLog2011 │ ├── ChangeLog2012 │ ├── ChangeLog2013 │ ├── ChangeLog2014 │ ├── DWARFDUMPCOPYRIGHT │ ├── GPL.txt │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── addrmap.c │ ├── addrmap.h │ ├── checkutil.c │ ├── checkutil.h │ ├── common.c │ ├── common.h │ ├── config.h.in │ ├── configure │ ├── configure.in │ ├── dwarf_tsearch.h │ ├── dwarf_tsearchbal.c │ ├── dwarfdump.1 │ ├── dwarfdump.c │ ├── dwarfdump.conf │ ├── dwconf.c │ ├── dwconf.h │ ├── dwgetopt.c │ ├── dwgetopt.h │ ├── esb.c │ ├── esb.h │ ├── getopttest.c │ ├── globals.h │ ├── install.sh │ ├── makename.c │ ├── makename.h │ ├── naming.c │ ├── naming.h │ ├── print_abbrevs.c │ ├── print_aranges.c │ ├── print_debugfission.c │ ├── print_die.c │ ├── print_frames.c │ ├── print_frames.h │ ├── print_gdbindex.c │ ├── print_lines.c │ ├── print_locs.c │ ├── print_macros.c │ ├── print_pubnames.c │ ├── print_ranges.c │ ├── print_reloc.c │ ├── print_reloc.h │ ├── print_sections.c │ ├── print_sections.h │ ├── print_static_funcs.c │ ├── print_static_vars.c │ ├── print_strings.c │ ├── print_types.c │ ├── print_weaknames.c │ ├── strstrnocase.c │ ├── tag_attr.c │ ├── tag_attr.list │ ├── tag_attr_ext.list │ ├── tag_common.c │ ├── tag_common.h │ ├── tag_tree.c │ ├── tag_tree.list │ ├── tag_tree_ext.list │ ├── testesb.c │ ├── uri.c │ ├── uri.h │ └── uritablebuild.c ├── dwarfexample │ ├── ChangeLog │ ├── ChangeLog2009 │ ├── ChangeLog2010 │ ├── ChangeLog2011 │ ├── ChangeLog2012 │ ├── ChangeLog2013 │ ├── ChangeLog2014 │ ├── Makefile │ ├── NEWS │ ├── frame1.c │ └── simplereader.c ├── dwarfgen │ ├── COPYING │ ├── ChangeLog │ ├── ChangeLog2011 │ ├── ChangeLog2012 │ ├── ChangeLog2013 │ ├── ChangeLog2014 │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── TESTmallocfail │ ├── config.h.in │ ├── configure │ ├── configure.in │ ├── createirepformfrombinary.cc │ ├── createirepfrombinary.cc │ ├── createirepfrombinary.h │ ├── dwarf-generator.txt │ ├── dwarfgen.1 │ ├── dwarfgen.cc │ ├── fakemalloc.in │ ├── general.h │ ├── install.sh │ ├── irepattrtodbg.cc │ ├── irepattrtodbg.h │ ├── irepdie.h │ ├── irepform.h │ ├── irepframe.h │ ├── irepline.h │ ├── irepmacro.h │ ├── ireppubnames.h │ ├── irepresentation.h │ ├── ireptodbg.cc │ ├── ireptodbg.h │ └── strtabdata.h ├── install.sh ├── libdwarf │ ├── CHANGES │ ├── CMakeLists.txt │ ├── CODINGSTYLE │ ├── COPYING │ ├── ChangeLog │ ├── ChangeLog2006 │ ├── ChangeLog2007 │ ├── ChangeLog2008 │ ├── ChangeLog2009 │ ├── ChangeLog2010 │ ├── ChangeLog2011 │ ├── ChangeLog2012 │ ├── ChangeLog2013 │ ├── ChangeLog2014 │ ├── LGPL.txt │ ├── LIBDWARFCOPYRIGHT │ ├── Makefile │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── cmplrs │ │ └── dwarf_addr_finder.h │ ├── common.c │ ├── common.h │ ├── config.h │ ├── config.h.in │ ├── config.log │ ├── config.status │ ├── configure │ ├── configure.in │ ├── dwarf.h │ ├── dwarf_abbrev.c │ ├── dwarf_abbrev.h │ ├── dwarf_addr_finder.c │ ├── dwarf_alloc.c │ ├── dwarf_alloc.h │ ├── dwarf_arange.c │ ├── dwarf_arange.h │ ├── dwarf_base_types.h │ ├── dwarf_die_deliv.c │ ├── dwarf_die_deliv.h │ ├── dwarf_elf_access.c │ ├── dwarf_elf_access.h │ ├── dwarf_error.c │ ├── dwarf_error.h │ ├── dwarf_form.c │ ├── dwarf_frame.c │ ├── dwarf_frame.h │ ├── dwarf_frame2.c │ ├── dwarf_frame3.c │ ├── dwarf_funcs.c │ ├── dwarf_funcs.h │ ├── dwarf_gdbindex.c │ ├── dwarf_gdbindex.h │ ├── dwarf_global.c │ ├── dwarf_global.h │ ├── dwarf_harmless.c │ ├── dwarf_harmless.h │ ├── dwarf_incl.h │ ├── dwarf_init_finish.c │ ├── dwarf_leb.c │ ├── dwarf_line.c │ ├── dwarf_line.h │ ├── dwarf_line2.c │ ├── dwarf_loc.c │ ├── dwarf_loc.h │ ├── dwarf_macro.c │ ├── dwarf_macro.h │ ├── dwarf_names.c │ ├── dwarf_names.h │ ├── dwarf_names_enum.h │ ├── dwarf_names_new.h │ ├── dwarf_opaque.h │ ├── dwarf_original_elf_init.c │ ├── dwarf_print_lines.c │ ├── dwarf_pubtypes.c │ ├── dwarf_query.c │ ├── dwarf_ranges.c │ ├── dwarf_reloc_arm.h │ ├── dwarf_reloc_mips.h │ ├── dwarf_reloc_ppc.h │ ├── dwarf_reloc_ppc64.h │ ├── dwarf_reloc_x86_64.h │ ├── dwarf_sort_line.c │ ├── dwarf_string.c │ ├── dwarf_stubs.c │ ├── dwarf_tsearch.h │ ├── dwarf_tsearchhash.c │ ├── dwarf_types.c │ ├── dwarf_types.h │ ├── dwarf_util.c │ ├── dwarf_util.h │ ├── dwarf_vars.c │ ├── dwarf_vars.h │ ├── dwarf_weaks.c │ ├── dwarf_weaks.h │ ├── dwarf_xu_index.c │ ├── dwarf_xu_index.h │ ├── dwgetopt.c │ ├── dwgetopt.h │ ├── gennames │ ├── gennames.c │ ├── install.sh │ ├── libdwarf.a │ ├── libdwarf.h │ ├── libdwarf.h.in │ ├── libdwarf2.1.mm │ ├── libdwarf2.1.pdf │ ├── libdwarf2p.1.mm │ ├── libdwarf2p.1.pdf │ ├── libdwarfdefs.h │ ├── malloc_check.c │ ├── malloc_check.h │ ├── mips_extensions.mm │ ├── mips_extensions.pdf │ ├── pro_alloc.c │ ├── pro_alloc.h │ ├── pro_arange.c │ ├── pro_arange.h │ ├── pro_die.c │ ├── pro_die.h │ ├── pro_encode_nm.c │ ├── pro_encode_nm.h │ ├── pro_error.c │ ├── pro_error.h │ ├── pro_expr.c │ ├── pro_expr.h │ ├── pro_finish.c │ ├── pro_forms.c │ ├── pro_frame.c │ ├── pro_frame.h │ ├── pro_funcs.c │ ├── pro_incl.h │ ├── pro_init.c │ ├── pro_line.c │ ├── pro_line.h │ ├── pro_macinfo.c │ ├── pro_macinfo.h │ ├── pro_opaque.h │ ├── pro_pubnames.c │ ├── pro_reloc.c │ ├── pro_reloc.h │ ├── pro_reloc_stream.c │ ├── pro_reloc_stream.h │ ├── pro_reloc_symbolic.c │ ├── pro_reloc_symbolic.h │ ├── pro_section.c │ ├── pro_section.h │ ├── pro_types.c │ ├── pro_types.h │ ├── pro_util.h │ ├── pro_vars.c │ └── pro_weaks.c └── tsearch │ ├── ChangeLog │ ├── ChangeLog2014 │ ├── ESSAY.txt │ ├── Makefile │ ├── README │ ├── RUNTEST │ ├── config.h │ ├── dwarf_incl.h │ ├── dwarf_tsearch.h │ ├── dwarf_tsearchbal.c │ ├── dwarf_tsearchbin.c │ ├── dwarf_tsearchepp.c │ ├── dwarf_tsearchhash.c │ ├── dwarf_tsearchred.c │ ├── scripts │ ├── TEST.sh │ ├── badsample │ ├── comparator.py │ ├── comparatorsample │ ├── concatlines.py │ ├── concatlinesample │ ├── secondsample │ └── testin │ ├── tsearch.c │ ├── tsearch_tester.c │ ├── tsearchlibtimes.csv │ └── tsearchlibtimes.ods └── libelf ├── CMakeLists.txt ├── COPYING.LIB ├── ChangeLog ├── INSTALL ├── MANIFEST ├── Makefile.in ├── README ├── VERSION ├── acconfig.h ├── aclocal.m4 ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.in ├── install-sh ├── lib ├── 32.fsize.c ├── 32.getehdr.c ├── 32.getphdr.c ├── 32.getshdr.c ├── 32.newehdr.c ├── 32.newphdr.c ├── 32.xlatetof.c ├── 64.xlatetof.c ├── CMakeLists.txt ├── Makefile.in ├── Makefile.w32 ├── assert.c ├── begin.c ├── build.bat ├── byteswap.h ├── checksum.c ├── cntl.c ├── config.h ├── config.h.w32 ├── cook.c ├── data.c ├── elf_repl.h ├── end.c ├── errmsg.c ├── errno.c ├── errors.h ├── ext_types.h ├── fill.c ├── flag.c ├── gelf.h ├── gelfehdr.c ├── gelfphdr.c ├── gelfshdr.c ├── gelftrans.c ├── getarhdr.c ├── getaroff.c ├── getarsym.c ├── getbase.c ├── getdata.c ├── getident.c ├── getscn.c ├── hash.c ├── input.c ├── kind.c ├── libelf.def ├── libelf.h ├── libelf │ ├── elf_repl.h │ └── sys_elf.h ├── memset.c ├── ndxscn.c ├── newdata.c ├── newscn.c ├── next.c ├── nextscn.c ├── nlist.c ├── nlist.h ├── opt.delscn.c ├── private.h ├── rand.c ├── rawdata.c ├── rawfile.c ├── strptr.c ├── swap64.c ├── sys_elf.h ├── sys_elf.h.in ├── sys_elf.h.w32 ├── update.c ├── verdef.h ├── verdef_32_tof.c ├── verdef_32_tom.c ├── verdef_64_tof.c ├── verdef_64_tom.c ├── verneed.h ├── version.c ├── x.elfext.c ├── x.movscn.c └── x.remscn.c ├── libelf.pc.in ├── mkinstalldirs ├── po ├── Makefile.in ├── de.gmo ├── de.msg ├── de.po ├── gmo2msg.c ├── libelf.pot └── stamp-po └── stamp-h.in /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /build/ 3 | /.cproject 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | # dev 4 | 5 | * Set a proper `RPATH` when installing the libraries on Linux and macOS. 6 | * Removed the `LIBDWARF_INSTALL_TO_UNITTESTS` CMake option. 7 | * Renamed built libraries to `libretdec-{libdwarf,libelf}.so` (similarly on Windows). 8 | 9 | # v1.0 (2017-12-12) 10 | 11 | Initial release. 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6) 2 | 3 | # Set the default build type to 'Release'. 4 | if(NOT CMAKE_BUILD_TYPE) 5 | set(default_build_type "Release") 6 | message(STATUS "Setting build type to '${default_build_type}' as none was specified.") 7 | set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) 8 | endif() 9 | 10 | # On Linux and macOS, set RPATH relative to the origin of the installed 11 | # libraries so that e.g. libdwarf can find libelf after installation. This 12 | # allows us to move the installation directory into a different location after 13 | # installation, which is useful e.g. when the installation is performed on one 14 | # machine but we want to run the executables on a different machine. 15 | # 16 | # On Windows, there is no need to set anything as DLLs are usually installed 17 | # into the binary directory, where they are automatically picked up by 18 | # executables. 19 | # 20 | # For more details, see 21 | # - https://cmake.org/Wiki/CMake_RPATH_handling 22 | if(APPLE) 23 | set(CMAKE_INSTALL_RPATH "@executable_path") 24 | elseif(UNIX) 25 | set(CMAKE_INSTALL_RPATH "$ORIGIN") 26 | endif() 27 | 28 | add_subdirectory(libdwarf) 29 | add_subdirectory(libelf) 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Libdwarf 2 | 3 | This repository is no longer alive. It is no longer needed by the RetDec [project](https://github.com/avast/retdec). It will be removed altogether after some transitional period. 4 | -------------------------------------------------------------------------------- /libdwarf/BLD: -------------------------------------------------------------------------------- 1 | 2 | set -x 3 | sh CLEANUP 4 | dobld () { 5 | cd $1 6 | if [ $? -ne 0 ] 7 | then 8 | echo FAIL CD in $1 9 | exit 1 10 | fi 11 | make distclean 12 | ./configure 13 | make 14 | if [ $? -ne 0 ] 15 | then 16 | echo FAIL BUILD in $1 17 | exit 1 18 | fi 19 | cd .. 20 | } 21 | dobld libdwarf 22 | dobld dwarfdump 23 | dobld dwarfgen 24 | cd dwarfexample 25 | if [ $? -ne 0 ] 26 | then 27 | echo FAIL BUILD a in dwarfexample 28 | exit 1 29 | fi 30 | make clean 31 | if [ $? -ne 0 ] 32 | then 33 | echo FAIL BUILD b in dwarfexample 34 | exit 1 35 | fi 36 | make 37 | if [ $? -ne 0 ] 38 | then 39 | echo FAIL BUILD c in dwarfexample 40 | exit 1 41 | fi 42 | -------------------------------------------------------------------------------- /libdwarf/BLDLIBDWARF: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | bldone () { 4 | t=$1 5 | cd $t 6 | # The following distclean will fail on a clean directory 7 | # Ignore the failure 8 | make distclean 9 | ./configure 10 | if [ $? != 0 ] 11 | then 12 | echo build failed 13 | exit 14 | fi 15 | make 16 | if [ $? != 0 ] 17 | then 18 | echo build failed 19 | exit 20 | fi 21 | cd .. 22 | } 23 | 24 | bldone libdwarf 25 | bldone dwarfdump 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /libdwarf/BLDLIBDWARFTAR: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | #newpref sets directory name with date, more 4 | #like normal linux packages. 5 | if [ $# != 1 ] 6 | then 7 | echo Usage: BLDLIBDWARFTAR yyyymmdd 8 | echo Example: BLDLIBDWARFTAR 20040108 9 | exit 1 10 | fi 11 | echo "This does not do UPDATEDWARFDUMPVERSION.sh" 12 | echo "Make sure there are no unwanted files" 13 | echo "in the code directories as all the files get" 14 | echo "copied to the release tar file." 15 | dat=$1 16 | 17 | tmpf=dwarf 18 | tmpdir=/var/tmp 19 | # cptopublic knows /var/tmp/dwarf is the target 20 | sh CPTOPUBLIC nouv 21 | newpref=dwarf-${dat} 22 | newf=libdwarf-${dat}.tar 23 | echo src is $tmpdir/$tmpf tmp is $newpref target is $newf 24 | echo ============ $newpref $newf ========== 25 | 26 | echo First create $tmpdir/$newpref with the latest source. 27 | cd $tmpdir 28 | if [ ! -d $tmpf ] 29 | then 30 | echo No $tmpdir/dwarf present! Do nothing. 31 | exit 0 32 | fi 33 | rm -rf $newpref 34 | 35 | cp -rp $tmpf $newpref 36 | # Alter date below before using.e 37 | rm -f ${newf} ${newf}.gz 38 | tar cf /var/tmp/$newf $newpref 39 | gzip ${newf} 40 | hm=/home/davea/web4/gweb/pagedata 41 | cp ${newf}.gz $hm 42 | ls -l $tmpdir/${newf}.gz 43 | ls -l $hm/${newf}.gz 44 | exit 0 45 | -------------------------------------------------------------------------------- /libdwarf/CLEANUP: -------------------------------------------------------------------------------- 1 | 2 | 3 | ( cd dwarfexample ; make clean ; make distclean ) 4 | ( cd dwarfgen ; make clean ; make distclean ) 5 | ( cd libdwarf ; make clean ; make distclean ) 6 | ( cd dwarfdump ; make clean ; make distclean ) 7 | rm -f dwarfgen/configure.lineno 8 | rm -f ALLd* 9 | rm -f junk* */junk* 10 | -------------------------------------------------------------------------------- /libdwarf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libdwarf C) 2 | 3 | add_subdirectory(libdwarf) 4 | -------------------------------------------------------------------------------- /libdwarf/CPTOPUBLIC: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # CPTOPUBLIC [uv] [nouv] 3 | 4 | usemsg() 5 | { 6 | echo "CPTOPUBLIC [uv] [nouv]" 7 | echo "where uv means update version strings " 8 | echo "where nouv means do not update version strings " 9 | echo "One of uv or nouv is required..." 10 | } 11 | 12 | if [ $# -ne 1 ] 13 | then 14 | usemsg 15 | exit 1 16 | fi 17 | uver="n" 18 | case $1 in 19 | uv) uver="y" ;; 20 | nouv) uver="n" ;; 21 | *) usemsg ; exit 1 ;; 22 | esac 23 | 24 | s=/home/davea/dwarf/code 25 | cd $s 26 | pwd 27 | t=/var/tmp/dwarf 28 | echo target is $t 29 | if [ $uver = "y" ] 30 | then 31 | sh UPDATEDWARFDUMPVERSION.sh 32 | fi 33 | rm -rf $t 34 | mkdir $t 35 | cp -rp * $t 36 | -------------------------------------------------------------------------------- /libdwarf/DECOMPILER_README: -------------------------------------------------------------------------------- 1 | # 2 | # What was done to libdwarf: 3 | # 4 | 5 | In file libdwarf/libdwarfdefs.h: 6 | typedef of __int32_t renamed to Dwarf__int32_t 7 | typedef of __uint32_t renamed to Dwarf__uint32_t 8 | typedef of __int64_t renamed to Dwarf__int64_t 9 | typedef of __uint64_t renamed to Dwarf__uint64_t 10 | ==> affected files: dwarf_base_types.h, pro_opaque 11 | 12 | In file dwarfdump2/globals.h: 13 | typedef of __int32_t renamed to Dwarfdump2__int32_t 14 | typedef of __uint32_t renamed to Dwarfdump2__uint32_t 15 | typedef of __int64_t renamed to Dwarfdump2__int64_t 16 | typedef of __uint64_t renamed to Dwarfdump2__uint64_t 17 | ==> affected files: print_die.cc, print_frames.cc 18 | 19 | All these occurrences were renamed, because they colide with system getopt library on windows: 20 | opterr -> libdwarf_opterr 21 | optind -> libdwarf_optind 22 | optopt -> libdwarf_optopt 23 | 24 | # 25 | # How to migrate to new version: 26 | # 27 | 28 | 1. 29 | Save old config.h and .make.mki files from all libdwarf parts that were built. 30 | 31 | 2. 32 | Replace libdwarf with new version. 33 | 34 | 3. 35 | Make libdwarf and other parts (dwarfump2, ...) with original Makefile. 36 | This will build config.h and generate some sources that are needed for our build. 37 | 38 | 4. 39 | Replace config.h files with original ones. Or at least check differences if making some changes. 40 | 41 | 5. 42 | Add our .make.mki files. Make sure they contain all needed source files - some might be new in new release. 43 | Make sure used sources do not have multiple main() functions - there might be multiple programs, do not 44 | compile them together. 45 | 46 | 6. 47 | Try to build it all. 48 | 49 | 50 | # 51 | # How to add bin-interface to dwarfdump2, ... 52 | # 53 | 54 | 1. 55 | bin-interface sources are in libdwarf/bin-interface/. 56 | Use them in all appplications, do not make separate copies - only one place to maintan/fix. 57 | 58 | 2. 59 | To add bin-interface support to dwarfdump2 see libdwarf/bin-interface/dwarfdump.add. 60 | 61 | 3. 62 | Add sources in libdwarf/bin-interface/ to other sources of the compiled application. 63 | I tried to create library from bin-interface and use it in dwarfdump2, but the same code 64 | that worked when compiled with other dwarfdump2 sources started to cause seg faults. 65 | -------------------------------------------------------------------------------- /libdwarf/NEWS: -------------------------------------------------------------------------------- 1 | 2015-01-13: Removed dwarfdump2 and references to it. 2 | dwarfdump has the (tsearch) features needed so the C++ 3 | version no longer a benefit. 4 | 5 | -------------------------------------------------------------------------------- /libdwarf/README: -------------------------------------------------------------------------------- 1 | To just build libdwarf and dwarfdump one might do: 2 | ./configure 3 | make dd 4 | #You may need to be root to do the following copy commands 5 | cp dwarfdump/dwarfdump /usr/local/bin 6 | cp dwarfdump/dwarfdump.conf /usr/local/lib 7 | #The following is optional, not needed to run dwarfdump 8 | #when doing the default build. 9 | cp libdwarf/libdwarf.a /usr/local/lib 10 | 11 | For a simple build of libdwarf, and dwarfdump 12 | and the other tools: 13 | ./configure 14 | make 15 | #Optionally: cp libdwarf/libdwarf.a 16 | 17 | To build all the tools (including dwarfgen and 18 | dwarfexample) use 'make all'. There are known 19 | small compile-time issues with building dwarfgen on 20 | MaxOSX and most don't need to build dwarfgen. 21 | ./configure 22 | make all 23 | 24 | To also build a shared libdwarf in the process, do: 25 | ./configure --enable-shared 26 | make 27 | cp libdwarf/libdwarf.so 28 | 29 | When ready to create a new distro, 30 | do 31 | ./CPTOPUBLIC 32 | ./BLDLIBDWARF yyyymmdd 33 | where that could be 34 | ./BLDLIBDWARF 20140131 35 | as an example. 36 | 37 | David Anderson. Updated December 28, 2014 (removed dwarfdump2) 38 | -------------------------------------------------------------------------------- /libdwarf/REBLDLIBDWARF: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Assume configure done recently. 3 | 4 | cd libdwarf 5 | if [ $? != 0 ] 6 | then 7 | echo build failed 8 | exit 9 | fi 10 | make 11 | if [ $? != 0 ] 12 | then 13 | echo build failed 14 | exit 15 | fi 16 | cd .. 17 | cd dwarfdump 18 | if [ $? != 0 ] 19 | then 20 | echo build failed 21 | exit 22 | fi 23 | # rm in case we changed libdwarf. 24 | rm dwarfdump 25 | make 26 | if [ $? != 0 ] 27 | then 28 | echo build failed 29 | exit 30 | fi 31 | cd .. 32 | -------------------------------------------------------------------------------- /libdwarf/SMBLDLIBDWARF: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/sh 3 | # 4 | 5 | cd libdwarf 6 | touch *.c 7 | CFLAGS="-g -O0 -DDWARF_SIMPLE_MALLOC" ./configure 8 | if [ $? != 0 ] 9 | then 10 | echo build failed 11 | exit 12 | fi 13 | make 14 | if [ $? != 0 ] 15 | then 16 | echo build failed 17 | exit 18 | fi 19 | cd .. 20 | cd dwarfdump 21 | rm dwarfdump 22 | touch *.c 23 | CFLAGS="-g -O0" ./configure 24 | if [ $? != 0 ] 25 | then 26 | echo build failed 27 | exit 28 | fi 29 | make 30 | if [ $? != 0 ] 31 | then 32 | echo build failed 33 | exit 34 | fi 35 | cd .. 36 | -------------------------------------------------------------------------------- /libdwarf/UPD.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | if (ARGC <= 2) { 3 | print "Bogus use of awk file, requires arg" 4 | exit 1 5 | } else { 6 | v=ARGV[1] 7 | ARGV[1]="" 8 | } 9 | } 10 | $0 ~ /#define DWARFDUMP_VERSION/ { print $1, $2, "\"",v,"\"" } 11 | $0 !~ /^#define DWARFDUMP_VERSION/ { print $0 } 12 | -------------------------------------------------------------------------------- /libdwarf/UPDATEDWARFDUMPVERSION.sh: -------------------------------------------------------------------------------- 1 | # Do not turn on -x here. it will screw things up! 2 | x=`date |tr '\n' ' '` 3 | cat > UPD.awk <<\EOF 4 | BEGIN { 5 | if (ARGC <= 2) { 6 | print "Bogus use of awk file, requires arg" 7 | exit 1 8 | } else { 9 | v=ARGV[1] 10 | ARGV[1]="" 11 | } 12 | } 13 | $0 ~ /#define DWARFDUMP_VERSION/ { print $1, $2, "\"",v,"\"" } 14 | $0 !~ /^#define DWARFDUMP_VERSION/ { print $0 } 15 | EOF 16 | awk -f UPD.awk "$x" dwarfdump/dwarfdump.c >t 17 | mv t dwarfdump/dwarfdump.c 18 | awk -f UPD.awk "$x" dwarfdump/common.c >t 19 | mv t dwarfdump/common.c 20 | -------------------------------------------------------------------------------- /libdwarf/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define if building universal (internal helper macro) */ 4 | #undef AC_APPLE_UNIVERSAL_BUILD 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_STDINT_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDLIB_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STRINGS_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRING_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_SYS_STAT_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_TYPES_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_UNISTD_H 32 | 33 | /* Define to the address where bug reports for this package should be sent. */ 34 | #undef PACKAGE_BUGREPORT 35 | 36 | /* Define to the full name of this package. */ 37 | #undef PACKAGE_NAME 38 | 39 | /* Define to the full name and version of this package. */ 40 | #undef PACKAGE_STRING 41 | 42 | /* Define to the one symbol short name of this package. */ 43 | #undef PACKAGE_TARNAME 44 | 45 | /* Define to the home page for this package. */ 46 | #undef PACKAGE_URL 47 | 48 | /* Define to the version of this package. */ 49 | #undef PACKAGE_VERSION 50 | 51 | /* Define to 1 if you have the ANSI C header files. */ 52 | #undef STDC_HEADERS 53 | 54 | /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most 55 | significant byte first (like Motorola and SPARC, unlike Intel). */ 56 | #if defined AC_APPLE_UNIVERSAL_BUILD 57 | # if defined __BIG_ENDIAN__ 58 | # define WORDS_BIGENDIAN 1 59 | # endif 60 | #else 61 | # ifndef WORDS_BIGENDIAN 62 | # undef WORDS_BIGENDIAN 63 | # endif 64 | #endif 65 | -------------------------------------------------------------------------------- /libdwarf/configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | dnlAC_INIT(libdwarf.h) 3 | AC_INIT() 4 | AC_CONFIG_HEADER(config.h) 5 | 6 | AC_PROG_CC 7 | AC_C_BIGENDIAN 8 | AC_GCC_TRADITIONAL 9 | AC_PROG_INSTALL 10 | AC_CHECK_TOOL(RANLIB, ranlib, :) 11 | AC_CHECK_TOOL(AR, ar) 12 | 13 | dnl libdwarf default-disabled shared 14 | shrd='' 15 | AC_ARG_ENABLE(shared,AC_HELP_STRING([--enable-shared], 16 | [build shared library libdwarf.so])) 17 | AS_IF([ test "x$enable_shared" = "xyes"], [ 18 | shrd='--enable-shared']) 19 | 20 | dnl We always build a non-shared so libdwarf 21 | dnl can use it itself as part of its build. 22 | dnl hence no --disable-nonshared provided here. 23 | 24 | chckres() { 25 | if test $1 != 0 26 | then 27 | echo "Configure Error exit: $2" 28 | exit 2 29 | fi 30 | } 31 | 32 | cd libdwarf 33 | echo "configuring libdwarf $shrd " 34 | ./configure "$shrd" 35 | chckres $? "libdwarf configure failed" 36 | echo "done configuring libdwarf $shrd " 37 | cd .. 38 | 39 | cd dwarfdump 40 | echo "configuring dwarfdump" 41 | ./configure 42 | chckres $? "dwarfdump configure failed" 43 | echo "done configuring dwarfdump" 44 | cd .. 45 | 46 | cd dwarfgen 47 | echo "configuring dwarfgen" 48 | ./configure 49 | chckres $? "dwarfgen configure failed" 50 | echo "done configuring dwarfgen" 51 | cd .. 52 | 53 | #dwarfexample: nothing to configure. 54 | 55 | AC_OUTPUT(Makefile) 56 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/CODINGSTYLE: -------------------------------------------------------------------------------- 1 | This document is a brief description of the main 2 | coding style conventions in dwarfdump. Many of them 3 | will be obvious from the code, but over time some 4 | accidental diffences crept in. 5 | 6 | 7 | Code should be indented in multiples of 4 spaces, and 8 | tabs should not be used to indent the source code. 9 | Use the dicheck program to check indenting. 10 | 11 | The struct naming convention is 'struct my_struct_s' for the 12 | struct defined here (meaning the name should end with _s). 13 | It is better to not do struct typedefs of local structs. 14 | Coders should type 'struct mystruct_s'. Readability 15 | is much more important than brevity. 16 | 17 | Any data or function not referenced outside the 18 | defining source file should be declared 'static'. 19 | 20 | Any duplicated code is a candidate for refactoring 21 | into a subprogram. 22 | 23 | Function names should be all lower case with underbars 24 | with the goal that statements and comments 'read well'. 25 | 26 | Variables should be lower-case with 27 | underbars for readability. It's ok for a small loop 28 | with counters to use single letter names like i or k or m. 29 | 30 | Structure members should have a struct-specific 31 | 2-character prefix to the name (followed by 32 | an underbar). That makes it much 33 | easier to grep for uses of members. 34 | 35 | Try to keep lines under 80 characters in length. 36 | 37 | Ensure every if() has {} to enclose the actions. 38 | 39 | Use libdwarf.h types for all the data objects you define, 40 | though sometimes an 'unsigned' or 'int' or 'size_t' is 41 | ok in restricted circumstances. Dwarf_Unsigned and 42 | Dwarf_Signed are the preferred integer types for general use. 43 | 44 | ------------ 45 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/COPYING: -------------------------------------------------------------------------------- 1 | 2 | David Anderson: December 2006 3 | The code in the dwarfdump directory is (if you look 4 | in each file) covered by the GPL (not the LGPL). The 5 | DWARFDUMPCOPYRIGHT file, though, said (before December 24, 6 | 2006) the copyright is LGPL. There is no doubt in my (David 7 | Anderson) mind that the intent was always that dwarfdump be 8 | GPL and the copyright markings in each file are correct. 9 | 10 | There are three files marked with the LGPL: tag_tree.list 11 | tag_attr.list acconfig.h. These markings are left as is and 12 | these are are therefore LGPL files. 13 | 14 | The DWARFDUMPCOPYRIGHT file now (Dec 24 2006) has both 15 | copyrights and an explanation of where each applies. 16 | 17 | 18 | 19 | ------------------------------------------- 20 | The text present for years, thru Dec 23, 2006: 21 | The files: 22 | dwarfdump.c 23 | and all the .h and .c files in this implementation of 24 | dwarfdump are copyrighted according to the file 25 | DWARFDUMPCOPYRIGHT. 26 | 27 | 28 | 29 | $Source: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/COPYING,v $ 30 | $Revision: 1.1 $ 31 | $Date: 2001/01/16 17:47:55 $ 32 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/addrmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 David Anderson. All rights reserved. 3 | 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms of version 2 of the GNU General Public License as 6 | published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it would be useful, but 9 | WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | Further, this software is distributed without any warranty that it is 13 | free of the rightful claim of any third person regarding infringement 14 | or the like. Any license provided herein, whether implied or 15 | otherwise, applies only to this software file. Patent licenses, if 16 | any, provided herein do not apply to combinations of this program with 17 | other software, or any other product whatsoever. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write the Free Software Foundation, Inc., 51 21 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 22 | 23 | */ 24 | 25 | struct Addr_Map_Entry { 26 | Dwarf_Unsigned mp_key; 27 | char * mp_name; 28 | }; 29 | 30 | struct Addr_Map_Entry * addr_map_insert(Dwarf_Unsigned addr, 31 | char *name, void **map); 32 | struct Addr_Map_Entry * addr_map_find(Dwarf_Unsigned addr, void **map); 33 | void addr_map_destroy(void *map); 34 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009-2010 SN Systems. All Rights Reserved. 3 | Portions Copyright (C) 2009-2010 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2 of the GNU General Public License as 7 | published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write the Free Software Foundation, Inc., 51 22 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 23 | */ 24 | 25 | #ifndef COMMON_INCLUDED_H 26 | #define COMMON_INCLUDED_H 27 | 28 | void print_args(int argc, char *argv[]); 29 | void print_version_details(const char *name, int alwaysprint); 30 | void print_usage_message(const char *program_name, const char **text); 31 | 32 | #endif /* COMMON_INCLUDED_H */ 33 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/dwgetopt.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: getopt.c,v 1.1 2009/03/22 22:33:13 joerg Exp $*/ 2 | /* Modified by David Anderson to work with GNU/Linux and freebsd. 3 | Added {} for clarity. 4 | Switched to standard dwarfdump formatting. 5 | Treatment of : modified so that :: gets optarg NULL 6 | if space follows the letter 7 | (the optarg is set to null). 8 | */ 9 | /* 10 | * Copyright (c) 1987, 1993, 1994 11 | * The Regents of the University of California. All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 3. Neither the name of the University nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 | * SUCH DAMAGE. 36 | */ 37 | 38 | extern int libdwarf_opterr; 39 | extern int libdwarf_optind; 40 | extern int libdwarf_optopt; 41 | extern int optreset; 42 | extern char *optarg; 43 | 44 | int dwgetopt(int nargc, char * const nargv[], const char *ostr); 45 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/makename.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 3 | 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms of version 2 of the GNU General Public License as 6 | published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it would be useful, but 9 | WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | Further, this software is distributed without any warranty that it is 13 | free of the rightful claim of any third person regarding infringement 14 | or the like. Any license provided herein, whether implied or 15 | otherwise, applies only to this software file. Patent licenses, if 16 | any, provided herein do not apply to combinations of this program with 17 | other software, or any other product whatsoever. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write the Free Software Foundation, Inc., 51 21 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 22 | 23 | makename.c 24 | $Revision: 1.4 $ 25 | $Date: 2005/11/08 21:48:42 $ 26 | 27 | This used to be elaborate stuff. 28 | Now it is trivial, as duplicating names is 29 | unimportant in dwarfdump (in general). 30 | 31 | And in fact, this is only called for attributes and 32 | tags etc whose true name is unknown. Not for 33 | any normal case. 34 | 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include "makename.h" 41 | 42 | #ifdef WIN32 43 | #pragma warning(disable:4996) /* Warning when migrated to VS2010 */ 44 | #endif /* WIN32 */ 45 | 46 | char * 47 | makename(const char *s) 48 | { 49 | char *newstr = 0; 50 | 51 | if (!s) { 52 | return ""; 53 | } 54 | 55 | newstr = (char *)strdup(s); 56 | if (newstr == 0) { 57 | fprintf(stderr, "Out of memory mallocing %d bytes\n", 58 | (int) strlen(s)); 59 | exit(1); 60 | } 61 | return newstr; 62 | } 63 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/makename.h: -------------------------------------------------------------------------------- 1 | #ifndef names_h 2 | #define names_h 3 | /* 4 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 5 | Portions Copyright 2011 David Anderson. All Rights Reserved. 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of version 2 of the GNU General Public License as 9 | published by the Free Software Foundation. 10 | 11 | This program is distributed in the hope that it would be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | Further, this software is distributed without any warranty that it is 16 | free of the rightful claim of any third person regarding infringement 17 | or the like. Any license provided herein, whether implied or 18 | otherwise, applies only to this software file. Patent licenses, if 19 | any, provided herein do not apply to combinations of this program with 20 | other software, or any other product whatsoever. 21 | 22 | You should have received a copy of the GNU General Public License along 23 | with this program; if not, write the Free Software Foundation, Inc., 51 24 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 25 | */ 26 | 27 | /* makename.h 28 | $Revision: 1.3 $ 29 | $Date: 2004/10/28 22:26:58 $ 30 | 31 | This is for putting strings into stable storage. 32 | 33 | Effectively an strdup() wrapper. 34 | 35 | Rarely called. 36 | 37 | It leaks memory, (the memory 38 | is never freed) but that seems unimportant since 39 | use of this is very rare. 40 | */ 41 | 42 | char * makename(const char *); /* Makes a copy of the string in 43 | a malloc area. Can never return 0. */ 44 | #endif 45 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/print_frames.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2 of the GNU General Public License as 7 | published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write the Free Software Foundation, Inc., 51 22 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 23 | */ 24 | 25 | int print_one_cie(Dwarf_Debug dbg, Dwarf_Cie cie, 26 | Dwarf_Unsigned cie_index, 27 | Dwarf_Half address_size, 28 | struct dwconf_s * config_data); 29 | 30 | void get_string_from_locs(Dwarf_Debug dbg, 31 | Dwarf_Ptr bytes_in, 32 | Dwarf_Unsigned block_len, 33 | Dwarf_Half addr_size, 34 | struct esb_s *out_string); 35 | 36 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/print_lines.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/dwarfdump/print_lines.c -------------------------------------------------------------------------------- /libdwarf/dwarfdump/print_reloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000,2004,2005 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright (C) 2007-2012 David Anderson. All Rights Reserved. 4 | Portions Copyright (C) 2011-2012 SN Systems Ltd. All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2 of the GNU General Public License as 8 | published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write the Free Software Foundation, Inc., 51 23 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 24 | */ 25 | 26 | #include "dwarf_reloc_arm.h" 27 | #include "dwarf_reloc_mips.h" 28 | #include "dwarf_reloc_ppc.h" 29 | #include "dwarf_reloc_ppc64.h" 30 | #include "dwarf_reloc_x86_64.h" 31 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/print_sections.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2 of the GNU General Public License as 7 | published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write the Free Software Foundation, Inc., 51 22 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 23 | */ 24 | 25 | 26 | extern int dwarf_names_print_on_error; 27 | 28 | void deal_with_name_offset_err(Dwarf_Debug dbg, 29 | char *err_loc, 30 | char *name, 31 | Dwarf_Unsigned die_off, 32 | int nres, 33 | Dwarf_Error err); 34 | 35 | Dwarf_Unsigned get_info_max_offset(Dwarf_Debug dbg); 36 | 37 | void print_pubname_style_entry(Dwarf_Debug dbg, 38 | char *line_title, 39 | char *name, 40 | Dwarf_Unsigned die_off, 41 | Dwarf_Unsigned cu_off, 42 | Dwarf_Unsigned global_cu_off, 43 | Dwarf_Unsigned maxoff); 44 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/print_strings.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. 4 | Portions Copyright 2009-2012 SN Systems Ltd. All rights reserved. 5 | Portions Copyright 2008-2012 David Anderson. All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of version 2 of the GNU General Public License as 9 | published by the Free Software Foundation. 10 | 11 | This program is distributed in the hope that it would be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | Further, this software is distributed without any warranty that it is 16 | free of the rightful claim of any third person regarding infringement 17 | or the like. Any license provided herein, whether implied or 18 | otherwise, applies only to this software file. Patent licenses, if 19 | any, provided herein do not apply to combinations of this program with 20 | other software, or any other product whatsoever. 21 | 22 | You should have received a copy of the GNU General Public License along 23 | with this program; if not, write the Free Software Foundation, Inc., 51 24 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 25 | 26 | */ 27 | 28 | #include "globals.h" 29 | #include "naming.h" 30 | #include "dwconf.h" 31 | #include "esb.h" 32 | 33 | #include "print_sections.h" 34 | 35 | /* print data in .debug_string */ 36 | extern void 37 | print_strings(Dwarf_Debug dbg) 38 | { 39 | Dwarf_Signed length = 0; 40 | string name; 41 | Dwarf_Off offset = 0; 42 | int sres = 0; 43 | 44 | current_section_id = DEBUG_STR; 45 | printf("\n.debug_string\n"); 46 | while ((sres = dwarf_get_str(dbg, offset, &name, &length, &err)) 47 | == DW_DLV_OK) { 48 | if (display_offsets) { 49 | printf("name at offset 0x%" DW_PR_XZEROS DW_PR_DUx 50 | ", length %4" DW_PR_DSd " is '%s'\n", 51 | (Dwarf_Unsigned)offset, length, name); 52 | } else { 53 | printf("name: length %4" DW_PR_DSd " is '%s'\n", 54 | length, name); 55 | } 56 | offset += length + 1; 57 | } 58 | /* An inability to find the section is not necessarily 59 | a real error, so do not report error unless we've 60 | seen a real record. */ 61 | if (sres == DW_DLV_ERROR && offset != 0) { 62 | print_error(dbg, "dwarf_get_str failure", sres, err); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/tag_tree_ext.list: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000-2010 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright 2009-2012 SN Systems Ltd. All rights reserved. 4 | Portions Copyright (C) 2009-2012 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 24 | USA. 25 | 26 | */ 27 | #include 28 | 29 | /* list for semantic check of tag-tree relation. 30 | See tag_tree.list for details. 31 | 32 | */ 33 | 34 | /* Common DWARF extensions */ 35 | 36 | 0xffffffff 37 | DW_TAG_structure_type 38 | DW_TAG_variable /* GNU gcc usage. */ 39 | DW_TAG_GNU_template_template_parameter /* template instantiations */ 40 | 0xffffffff 41 | DW_TAG_class_type 42 | DW_TAG_variable /* GNU gcc usage. */ 43 | DW_TAG_GNU_template_template_parameter /* template instantiations */ 44 | 0xffffffff 45 | DW_TAG_subprogram 46 | DW_TAG_GNU_call_site 47 | DW_TAG_GNU_template_template_parameter /* template instantiations */ 48 | 0xffffffff 49 | DW_TAG_union_type 50 | DW_TAG_GNU_template_template_parameter /* template instantiations */ 51 | 0xffffffff 52 | DW_TAG_inlined_subroutine 53 | DW_TAG_GNU_call_site 54 | 0xffffffff 55 | DW_TAG_GNU_call_site 56 | DW_TAG_GNU_call_site_parameter 57 | 0xffffffff 58 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/testesb.c: -------------------------------------------------------------------------------- 1 | /* testesb.c 2 | test code for esb.h esb.c 3 | 4 | Not part of a compiled dwarfdump. 5 | 6 | */ 7 | 8 | #include 9 | #include /* For va_start va_arg va_list */ 10 | #include 11 | typedef char *string; 12 | 13 | #include "esb.h" 14 | 15 | void 16 | check(string msg, struct esb_s *data, string v) 17 | { 18 | string b = esb_get_string(data); 19 | size_t l = 0; 20 | size_t alloc = 0; 21 | 22 | if (strcmp(b, v)) { 23 | fprintf(stderr, "ERROR: %s content error %s != %s\n", msg, b, 24 | v); 25 | } 26 | 27 | l = esb_string_len(data); 28 | 29 | if (l != strlen(v)) { 30 | fprintf(stderr, "ERROR: %s length error %lu != %lu\n", msg, 31 | (unsigned long) l, (unsigned long) strlen(v)); 32 | } 33 | alloc = esb_get_allocated_size(data); 34 | if (l > alloc) { 35 | fprintf(stderr, "ERROR: %s allocation error %lu > %lu\n", msg, 36 | (unsigned long) l, (unsigned long) alloc); 37 | 38 | } 39 | 40 | return; 41 | } 42 | 43 | int 44 | main(void) 45 | { 46 | struct esb_s data; 47 | 48 | 49 | esb_alloc_size(2); /* small to get all code paths tested. */ 50 | esb_constructor(&data); 51 | 52 | esb_append(&data, "a"); 53 | esb_appendn(&data, "bc", 1); 54 | esb_append(&data, "d"); 55 | esb_append(&data, "e"); 56 | check("test 1", &data, "abde"); 57 | 58 | esb_destructor(&data); 59 | esb_constructor(&data); 60 | 61 | esb_append(&data, "abcdefghij" "0123456789"); 62 | check("test 2", &data, "abcdefghij" "0123456789"); 63 | 64 | esb_destructor(&data); 65 | esb_constructor(&data); 66 | esb_append(&data, "abcdefghij" "0123456789"); 67 | 68 | esb_append(&data, "abcdefghij" "0123456789"); 69 | 70 | esb_append(&data, "abcdefghij" "0123456789"); 71 | 72 | esb_append(&data, "abcdefghij" "0123456789"); 73 | check("test 3", &data, "abcdefghij" 74 | "0123456789" 75 | "abcdefghij" 76 | "0123456789" 77 | "abcdefghij" "0123456789" "abcdefghij" "0123456789"); 78 | esb_destructor(&data); 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /libdwarf/dwarfdump/uri.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 David Anderson. All rights reserved. 3 | 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms of version 2 of the GNU General Public License as 6 | published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it would be useful, but 9 | WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | Further, this software is distributed without any warranty that it is 13 | free of the rightful claim of any third person regarding infringement 14 | or the like. Any license provided herein, whether implied or 15 | otherwise, applies only to this software file. Patent licenses, if 16 | any, provided herein do not apply to combinations of this program with 17 | other software, or any other product whatsoever. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write the Free Software Foundation, Inc., 51 21 | Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. 22 | */ 23 | 24 | void translate_to_uri(const char * filename, struct esb_s *out); 25 | void translate_from_uri(const char * input, struct esb_s *out); 26 | 27 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog: -------------------------------------------------------------------------------- 1 | 2015-05-05 David Anderson 2 | * simplereader.c: Added code to help testing 3 | in libdwarf DebugFission Package File interfaces. 4 | 2015-01-01 David Anderson 5 | * A new year begins. 6 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog2009: -------------------------------------------------------------------------------- 1 | August 7, 2009 David Anderson 2 | * frame1.c: This is a new example that uses frame functions. 3 | July 21, 2009 David Anderson 4 | * simplereader.c: After cur_die = sib_die; nothing was printing 5 | cur_die, so added a print call after the assignment. 6 | July 8, 2009 David Anderson 7 | * Makefile: New trivial Makefile to build the example. 8 | * simplereader.c: New trivial example using libdwarf. 9 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog2010: -------------------------------------------------------------------------------- 1 | April 26, 2010 David Anderson 2 | * simplereader.c: Now prints all TAGs regardless of 3 | whether a DIE has a DW_AT_name attribute. All names 4 | print an "" pair so it's easy to recognize empty names 5 | and names with embedded spaces. 6 | March 31, 2010 David Anderson 7 | * simplereader.c: Added a new option --names which 8 | shows additional detail on getting attributes and source 9 | file information. 10 | January 3, 2010 David Anderson 11 | * frame1.c, simplereader.c: Update copyright year. 12 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog2011: -------------------------------------------------------------------------------- 1 | 2011-06-04 DavidAnderson 2 | * frame1.c, simplereader.c: Altered indentation to 3 | multiples of 4 spaces, no tabs. No substantive change. 4 | 2011-01-13 DavidAnderson 5 | * New year starts. 6 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog2012: -------------------------------------------------------------------------------- 1 | No changes in 2012. 2 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog2013: -------------------------------------------------------------------------------- 1 | 2013-11-24 David Anderson 2 | * Makefile: Some compilers (FreeBSD gcc, for example) do 3 | not support -gdwarf-4, so changed the compile 4 | to -g. 5 | 2013-08-13 David Anderson 6 | * Add the --check option to verify that dwarf_highpc() 7 | and the new dwarf_highpc_b() work properly with 8 | both form address and form constant instances of 9 | attributes DW_AT_high_pc. 10 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/ChangeLog2014: -------------------------------------------------------------------------------- 1 | 2014-01-30 David Anderson 2 | * simplereader.c: Removed dwarf_dealloc from call of string 3 | returned by dwarf_diename(). The dwarf_diename() call 4 | was incorrectly documented. 5 | 2014-01-29 David Anderson 6 | * frame1.c,simplereader.c: Remove trailing whitespace. 7 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | LIBDIR= -L../libdwarf 4 | LIBS= -ldwarf -lelf 5 | # FreeBSD gcc has -g -gdwarf-2 not -gdwarf-4 6 | CFLAGS= -g -Wall -I../libdwarf 7 | 8 | all: simplereader frame1 9 | 10 | simplereader: simplereader.c 11 | $(CC) $(CFLAGS) simplereader.c -o simplereader $(LIBDIR) $(LIBS) 12 | frame1: frame1.c 13 | $(CC) $(CFLAGS) frame1.c -o frame1 $(LIBDIR) $(LIBS) 14 | 15 | clean: 16 | rm -f simplereader.o 17 | rm -f simplereader 18 | rm -f frame1 19 | rm -f frame1.o 20 | -------------------------------------------------------------------------------- /libdwarf/dwarfexample/NEWS: -------------------------------------------------------------------------------- 1 | July 21, 2009 2 | Roni Simonian noticed a call to print_die_data(dbg,cur_die,in_level); 3 | was missing so not all DIEs would print. Good Catch! 4 | July 8, 2009 5 | Created a sample libdwarf consumer. Using BSD license so 6 | anyone can use it. And a trivial Makefile. 7 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/COPYING: -------------------------------------------------------------------------------- 1 | Files here are copyrighted by David Anderson 2 | (and possibly others, see the copyright notices in individual 3 | files) by the BSD3 copyright (BSD3 is what it is normally called). 4 | 5 | A typical notice is: 6 | 7 | Copyright (C) 2010-2013 David Anderson. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the example nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY 21 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | David Anderson is at 32 | libdwarf-list -at- earthlink =dot= net 33 | 34 | 280 Bella Vista Drive 35 | Hillsborough, California 94010 36 | USA. 37 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/ChangeLog: -------------------------------------------------------------------------------- 1 | 2015-02-22 David Anderson 2 | * Now uses dwgetopt.h, .c from dwarfdump. 3 | * dwarfgen.cc: Now references dwgetopt.h and dwgetopt(). 4 | * Makefile.in: Reaches around to libdwarf for dwgetopt. 5 | * configure.in: Removed getopt.h check 6 | * configure: regenerated 7 | 2015-01-06 David Anderson 8 | * dwarfgen.cc: Fixed indents and removed trailing whitespace. 9 | 2015-01-01 David Anderson 10 | * A new year begins. 11 | 12 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/ChangeLog2011: -------------------------------------------------------------------------------- 1 | 2 | 2011-11-17 DavidAnderson 3 | * createirepformfrombinary.cc,createirepfrombinary.cc, 4 | irepattrtodbg.cc: Update copyright year. 5 | 2011-12-14 DavidAnderson 6 | * createirepfrombinary.cc, dwarfgen.cc, general.h, 7 | irepattrtodbg.cc, irepdie.h, irepline.h, 8 | irepresentation.h, ireptodbg.cc: Now reads in line table 9 | and creates line table output (still just DWARF2 though). 10 | 2011-06-12 DavidAnderson 11 | * dwarfgen.cc: Use dwarf_producer_init_c(), the newest 12 | interface to the producer. 13 | 2011-04-23 DavidAnderson 14 | * createirepformfrombinary.cc, createirepfrombinary.cc, 15 | dwarfgen.cc,general.h,irepattrtodbg.cc, 16 | irepattrtodbg.h,irepdie.h, 17 | irepform.h,irepframe.h,irepmacro.h,irepresentation.h,ireptodbg.cc, 18 | reptodbg.h,strtabdata.h: All the indentation is a multiple of 4 now. 19 | All the copyrights are updated. 20 | 21 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/ChangeLog2012: -------------------------------------------------------------------------------- 1 | ChangeLog2012 is empty, no changes in 2012. 2 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/ChangeLog2014: -------------------------------------------------------------------------------- 1 | 2014-12-28 David Anderson 2 | * fakemalloc.c: Renamed to fakemalloc.in . 3 | 2014-12-28 David Anderson 4 | * fakemalloc.c,TESTmallocfail: This makes possible 5 | a simple test that we handle malloc failure 6 | as sensible as possible. The test requires hand 7 | modification of the dwarfgen Makefile. 8 | * createirepfrombinary.cc: Now prints the libdwarf error 9 | number for better error reporting when there is a libdwarf 10 | error (running out of malloc space, for example). 11 | 2014-12-09 David Anderson 12 | * dwarfgen.cc: Add try/catch for bad malloc and 13 | any other disasters.. 14 | Add dwarfgen in the string for all the errors 15 | leading to exit 16 | * dwarf_tsearchhash.c: Add check for NULL return 17 | in tsearch_inner() so we don't just core dump 18 | when malloc fails. 19 | 2014-05-08 David Anderson 20 | * dwarfgen.cc: Now uses the newest form of dwarf_producer_init(). 21 | The old forms no longer are supported. 22 | 2014-02-08 David Anderson 23 | * dwarfgen.cc: Added commentary about the callback function 24 | setting sect_name_index. 25 | 2014-01-29 David Anderson 26 | * createirepformfrombinary.cc,createirepfrombinary.cc,createirepfrombinary.h, 27 | dwarfgen.cc,general.h,irepattrtodbg.cc,irepattrtodbg.h,irepdie.h, 28 | irepform.h,irepframe.h,irepline.h,irepmacro.h,ireppubnames.h, 29 | irepresentation.h,ireptodbg.cc,ireptodbg.h,strtabdata.h: Remove 30 | trailing whitespace. 31 | 2014-01-10 David Anderson 32 | * createirepformfrombinary.cc,createirepfrombinary.cc,dwarfgen.cc, 33 | irepattrtodbg.cc,ireptodbg.cc: Removed include of elf.h as it 34 | is not needed given the include of gelf.h. 35 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile.in uses very simple make rules. 3 | # There are no restrictions on copying this file. 4 | # 5 | 6 | # Standard Makefile.in stuff: 7 | srcdir = @srcdir@ 8 | VPATH = @srcdir@ 9 | 10 | prefix = @prefix@ 11 | exec_prefix = @exec_prefix@ 12 | bindir = $(exec_prefix)/bin 13 | libdir = $(exec_prefix)/lib 14 | mandir = $(exec_prefix)/share/man 15 | man1dir = $(mandir)/man1 16 | 17 | INSTALL = @INSTALL@ 18 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 19 | INSTALL_DATA = @INSTALL_DATA@ 20 | DATAROOT = @datarootdir@ 21 | SHELL = /bin/sh 22 | CXX = @CXX@ 23 | AR = @AR@ 24 | #ARFLAGS = @ARFLAGS@ 25 | RM = rm 26 | RANLIB = @RANLIB@ 27 | DEFS = @DEFS@ 28 | LIBS = @LIBS@ -L ../libdwarf -ldwarf -lelf 29 | INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libdwarf 30 | CXXFLAGS = @CXXFLAGS@ $(INCLUDES) 31 | LDFLAGS = @LDFLAGS@ $(LIBS) 32 | 33 | 34 | DIRINC = $(srcdir)/../libdwarf 35 | INSTALL = cp 36 | 37 | binprefix = 38 | 39 | DGOBJECTS = \ 40 | createirepformfrombinary.o \ 41 | createirepfrombinary.o \ 42 | dwarfgen.o \ 43 | irepattrtodbg.o \ 44 | ireptodbg.o 45 | 46 | HEADERS = \ 47 | createirepfrombinary.h\ 48 | general.h \ 49 | irepattrtodbg.h \ 50 | irepdie.h \ 51 | irepframe.h \ 52 | irepform.h \ 53 | irepmacro.h \ 54 | irepresentation.h \ 55 | ireptodbg.h \ 56 | strtabdata.h 57 | 58 | all: dwarfgen 59 | 60 | default: $(TARGETS) 61 | 62 | # We reach-around to libdwarf to get the dwgetopt src, header. 63 | # We could equally well reach around to dwarfdump. 64 | dwgetopt.o: $(srcdir)/../libdwarf/dwgetopt.c $(srcdir)/../libdwarf/dwgetopt.h 65 | $(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/../libdwarf/dwgetopt.c 66 | dwarfgen: $(HEADERS) $(DGOBJECTS) dwgetopt.o 67 | $(CXX) $(CXXFLAGS) -o $@ $(DGOBJECTS) $(LDFLAGS) dwgetopt.o 68 | 69 | test: 70 | 71 | install: all 72 | $(INSTALL) $(srcdir)/dwarfgen.conf $(libdir)/dwarfgen.conf 73 | $(INSTALL) $(srcdir)/dwarfgen.1 $(man1dir)/dwarfgen.1 74 | $(INSTALL) dwarfgen $(bindir)/dwarfgen 75 | 76 | clean: 77 | -rm -f *.o dwarfgen 78 | 79 | uninstall: 80 | -rm -f $(libdir)/dwarfgen.conf 81 | -rm -f $(man1dir)/dwarfgen.1 82 | -rm -f $(bindir)/dwarfgen 83 | 84 | distclean: clean 85 | -rm -f config.log config.h config.cache config.status 86 | rm -rf autom4te.cache 87 | rm -f Makefile 88 | 89 | shar: 90 | @echo "shar not set up." 91 | 92 | dist: 93 | @echo "dist not set up." 94 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/NEWS: -------------------------------------------------------------------------------- 1 | 26 February, 2015 2 | Now uses dwgetopt() instead of getopt() so all environments 3 | have a getopt-like functionality. It reaches around to 4 | libdwarf for the source to dwgetopt, but it could 5 | equally well reach into dwarfdump for that source. 6 | 7 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/README: -------------------------------------------------------------------------------- 1 | 2 | David Anderson, September 20, 2010 3 | 4 | The dwarfgen application is intended as both a vehicle 5 | for testing dwarf-generation by libdwarf and as an example 6 | of how one uses libdwarf to generate DWARF. 7 | In addition, it should be useful as a test vehicle for 8 | evaluating future changes to the DWARF standard. 9 | 10 | It is necessary as a test-vehicle so that the libdwarf 11 | producer code can be updated to allow more recent features 12 | of DWARF to be supported while trying to guarantee current 13 | producer code users are correctly supported. 14 | 15 | By default dwarfgen produces a fake a.out. By that we mean 16 | that no relocation sections are written. Instead, relocations 17 | are processed directly by dwarfgen. 18 | Perhaps at some point a more a.out-like output will be optionally 19 | supported. 20 | 21 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/TESTmallocfail: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This runs dwarfgen/libdwarf with a malloc failure 4 | # at the $ct'th call to malloc. 5 | # To expose errors in malloc failure handling. 6 | 7 | # Probably any small C file compiled -c will do 8 | # to produce test.o For example just use a .o 9 | # generated by the build of dwarfgen 10 | 11 | subj=test.o 12 | ct=0 13 | 14 | while [ $ct -lt 500 ] 15 | do 16 | echo '===== START TEST' 17 | rm -f core 18 | rm -f dwarfgen 19 | sed -e "s/FAILCOUNT/$ct/" fakemalloc.c 20 | echo TEST $ct 21 | grep if fakemalloc.c 22 | make 23 | ./dwarfgen -h -t obj -c 0 -o $subj ./dwarfgen >junk.x 24 | cat junk.x 25 | if [ -f core ] 26 | then 27 | echo "CORE FILE EXISTS, test" $ct 28 | fi 29 | rm -f core 30 | echo '===== END TEST' 31 | ct=`expr $ct + 1` 32 | done 33 | 34 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define if building universal (internal helper macro) */ 4 | #undef AC_APPLE_UNIVERSAL_BUILD 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_ELF_H 8 | 9 | /* Define 1 if intptr_t defined in C99 stdint.h */ 10 | #undef HAVE_INTPTR_T 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_INTTYPES_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_LIBELF_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_MEMORY_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_SGIDEFS_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STDINT_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STDLIB_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_STRINGS_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_STRING_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_SYS_STAT_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_SYS_TYPES_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_UNISTD_H 44 | 45 | /* Define 1 if __uint32_t is in sgidefs.h. */ 46 | #undef HAVE___UINT32_T_IN_SGIDEFS_H 47 | 48 | /* Define 1 if is in sgidefs.h. */ 49 | #undef HAVE___UINT64_T_IN_SGIDEFS_H 50 | 51 | /* Define to the address where bug reports for this package should be sent. */ 52 | #undef PACKAGE_BUGREPORT 53 | 54 | /* Define to the full name of this package. */ 55 | #undef PACKAGE_NAME 56 | 57 | /* Define to the full name and version of this package. */ 58 | #undef PACKAGE_STRING 59 | 60 | /* Define to the one symbol short name of this package. */ 61 | #undef PACKAGE_TARNAME 62 | 63 | /* Define to the home page for this package. */ 64 | #undef PACKAGE_URL 65 | 66 | /* Define to the version of this package. */ 67 | #undef PACKAGE_VERSION 68 | 69 | /* Define to 1 if you have the ANSI C header files. */ 70 | #undef STDC_HEADERS 71 | 72 | /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most 73 | significant byte first (like Motorola and SPARC, unlike Intel). */ 74 | #if defined AC_APPLE_UNIVERSAL_BUILD 75 | # if defined __BIG_ENDIAN__ 76 | # define WORDS_BIGENDIAN 1 77 | # endif 78 | #else 79 | # ifndef WORDS_BIGENDIAN 80 | # undef WORDS_BIGENDIAN 81 | # endif 82 | #endif 83 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/configure.in: -------------------------------------------------------------------------------- 1 | dnl This is input to autoconf, producing a configure script. 2 | AC_INIT(dwarfgen.cc) 3 | AC_CONFIG_HEADER(config.h) 4 | 5 | AC_PROG_CC 6 | AC_PROG_CXX 7 | AC_C_BIGENDIAN 8 | AC_GCC_TRADITIONAL 9 | AC_PROG_INSTALL 10 | AC_CHECK_TOOL(RANLIB, ranlib, :) 11 | AC_CHECK_TOOL(AR, ar) 12 | 13 | AC_CHECK_HEADERS(elf.h libelf.h sgidefs.h sys/types.h) 14 | 15 | dnl Attempt to determine if it is really IRIX/SGI or 'other'. 16 | AC_TRY_COMPILE([#include ],[ __uint32_t p; p = 27;] , 17 | AC_DEFINE(HAVE___UINT32_T_IN_SGIDEFS_H,1, 18 | [Define 1 if __uint32_t is in sgidefs.h.])) 19 | AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , 20 | AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, 21 | [Define 1 if __uint64_t is in sgidefs.h.])) 22 | AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , 23 | AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, 24 | [Define 1 if is in sgidefs.h.])) 25 | dnl the existence of sgidefs.h does not prove it's truly SGI, nor 26 | dnl prove that __uint32_t or __uint64_t is defined therein. 27 | AC_TRY_COMPILE([#include ],[ __uint32_t p; p = 27;] , 28 | AC_DEFINE(HAVE___UINT32_T_IN_SGIDEFS_H,1, 29 | [Define 1 if __uint32_t is in sgidefs.h.])) 30 | AC_TRY_COMPILE([#include ],[intptr_t p; p = 27;] , 31 | AC_DEFINE(HAVE_INTPTR_T,1, 32 | [Define 1 if intptr_t defined in C99 stdint.h])) 33 | AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , 34 | AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, 35 | [Define 1 if __uint64_t is in sgidefs.h.])) 36 | AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , 37 | AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, 38 | [Define 1 if is in sgidefs.h.])) 39 | 40 | 41 | AC_OUTPUT(Makefile) 42 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/createirepfrombinary.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010-2013 David Anderson. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the example nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY 16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | */ 27 | 28 | // createirepfrombinary.h 29 | 30 | 31 | void createIrepFromBinary(const std::string &infile, 32 | IRepresentation & irep); 33 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/dwarf-generator.txt: -------------------------------------------------------------------------------- 1 | Speculative thoughts on using a script to define what 2 | DWARF? to write out in an elf file: 3 | 4 | Syntax for dw tab entry 5 | # is comment 6 | levels by indentation like python 7 | attrs. indent to the tag they apply to. 8 | 9 | ;section x 10 | ;endsection x 11 | 12 | :label: 13 | [] tag 14 | attr [form name] value 15 | 16 | any attr or tag may have a label. 17 | 18 | Various forms require specific value formats. 19 | values sometims require offsets such as a sibling ref 20 | or a fwd/rev ref or a ref to the debug_loc sec 21 | 22 | 23 | DW_FORM_data 1,2 integer 24 | DW_FORM_data 4,8 integer or offset depends on context 25 | DW_FORM_sdata, udata integer 26 | DW_FORM_string "string value" 27 | DW_FORM_strp "string value" 28 | DW_FORM_block 1,2,4,8 blk-fmt 29 | 30 | this is blk_fmt 31 | hex number 32 | decimal number 33 | [ dw-expr] 34 | 35 | 36 | sythetic forms: 37 | DW_FORM_loclist [label | loclist-itself] 38 | 39 | loclist-itself 40 | offset offset DW_FORM_block [blk_fmt] 41 | ... 42 | 43 | DW_FORM_maclist label 44 | DW_FORM_? 45 | 46 | Line table entries 47 | 48 | CIE entries 49 | 50 | FDE entries 51 | 52 | 53 | mac sec entries 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/dwarfgen.1: -------------------------------------------------------------------------------- 1 | .TH DWARFGEN 2 | .SH NAME 3 | dwarfgen \- Generate example DWARF data. 4 | .SH SYNOPSIS 5 | .B dwarfgen 6 | .SH DESCRIPTION 7 | The 8 | .B dwarfgen 9 | command creates DWARF sections as requested by specific options. 10 | The command is under development as of January 2010. 11 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/fakemalloc.in: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a simple way (on Linux) to do a certain kind 4 | of test. "Code Testing Through Fault Injection" in ":login;" 5 | magazine (December, 2014. Usenix.org) by Peter Gutmann offered 6 | a simple example by an unnamed friend: instrument malloc() so 7 | on call N it returns NULL. Try with N from 0 to some higher 8 | number (I used 0 to 100). Run your chosen executable and 9 | see how it fares. This test exposed a couple bugs in libdwarf. 10 | 11 | Here are some of the example core dumps (running dwarfgen): 12 | 2000: Could not allocate Dwarf_Error structure, abort() in libdwarf. 13 | 1000: FAIL:bad alloc caughtstd::bad_alloc 14 | 500: FAIL:bad alloc caughtstd::bad_alloc 15 | 250: FAIL:bad alloc caughtstd::bad_alloc 16 | 125: Could not allocate Dwarf_Error structure, abort() in libdwarf. 17 | Aborted (core dumped) 18 | 100: FAIL:bad alloc caughtstd::bad_alloc 19 | 46-60: FAIL:bad alloc caughtstd::bad_alloc 20 | 45- Could not allocate Dwarf_Error structure, abort() in libdwarf. 21 | Aborted (core dumped) 22 | 42-44: FAIL:bad alloc caughtstd::bad_alloc 23 | 30- 41: Could not allocate Dwarf_Error structure, abort() in libdwarf. 24 | Aborted (core dumped) 25 | 28-29 :FAIL:bad alloc caught std::bad_alloc 26 | Aborted (core dumped) 27 | 28 | 8,9,10,11-27: Could not allocate Dwarf_Error structure, abort() in libdwarf. 29 | Aborted (core dumped) 30 | 7: 6: FAIL:bad alloc caught std::bad_alloc 31 | 32 | 0,1,2,3,4,5: terminate called after throwing an instance of 'std::bad_alloc' 33 | what(): std::bad_alloc 34 | Aborted (core dumped) 35 | 36 | -------HOW TO USE: 37 | Configure generates the following for Makefile. 38 | $(CXX) $(CXXFLAGS) -o $@ $(DGOBJECTS) $(LDFLAGS) 39 | 40 | In the generated Makefile, replace the above line with 41 | these two lines. 42 | $(CC) $(CFLAGS) -c fakemalloc.o 43 | $(CXX) $(CXXFLAGS) -o $@ $(DGOBJECTS) $(LDFLAGS) fakemalloc.o 44 | 45 | Run tests using the script TESTmallocfail 46 | ------- 47 | 48 | */ 49 | 50 | static unsigned count; 51 | extern void * __libc_malloc(); 52 | 53 | void *malloc(unsigned len) 54 | { 55 | /* Perhaps the test should be count >= FAILCOUNT ??? */ 56 | if (count == FAILCOUNT) { 57 | return 0; 58 | } 59 | count++; 60 | return __libc_malloc(len); 61 | } 62 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/irepattrtodbg.h: -------------------------------------------------------------------------------- 1 | #ifndef IREPATTRTODBG_H 2 | #define IREPATTRTODBG_H 3 | /* 4 | Copyright (C) 2010-2013 David Anderson. All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the example nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | */ 29 | 30 | // irepattrtodbg.h 31 | 32 | void AddAttrToDie(Dwarf_P_Debug dbg, 33 | IRepresentation & Irep, 34 | IRCUdata &cu, 35 | Dwarf_P_Die outdie,IRDie & irdie,IRAttr &irattr); 36 | 37 | #endif /* IREPATTRTODBG_H */ 38 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/irepmacro.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010-2013 David Anderson. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the example nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY 16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | */ 27 | 28 | // 29 | // irepmacro.h 30 | // 31 | 32 | class IRMacroRecord { 33 | public: 34 | IRMacroRecord() {}; 35 | ~IRMacroRecord() {}; 36 | IRMacroRecord(Dwarf_Off cuDieOffset,Dwarf_Off offset,Dwarf_Small type, 37 | Dwarf_Signed lineno, Dwarf_Signed lineindex, 38 | const std::string ¯o):cuDieOffset_(cuDieOffset), 39 | offset_(offset), 40 | type_(type),lineno_(lineno),lineindex_(lineindex), 41 | macro_(macro) {}; 42 | private: 43 | Dwarf_Off cuDieOffset_; 44 | Dwarf_Off offset_; 45 | Dwarf_Small type_; 46 | Dwarf_Signed lineno_; 47 | Dwarf_Signed lineindex_; 48 | std::string macro_; 49 | }; 50 | class IRMacro { 51 | public: 52 | IRMacro() {}; 53 | ~IRMacro() {}; 54 | std::vector &getMacroVec() { return macrorec_; }; 55 | private: 56 | std::vector macrorec_; 57 | }; 58 | -------------------------------------------------------------------------------- /libdwarf/dwarfgen/ireptodbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010-2013 David Anderson. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the example nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY 16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | */ 27 | 28 | 29 | 30 | // ireptodbg.h 31 | 32 | 33 | void transform_irep_to_dbg(Dwarf_P_Debug dbg, IRepresentation & Irep, 34 | int cu_of_input_we_output); 35 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBDWARF_SOURCES 2 | common.c 3 | dwarf_abbrev.c 4 | dwarf_addr_finder.c 5 | dwarf_alloc.c 6 | dwarf_arange.c 7 | dwarf_die_deliv.c 8 | dwarf_elf_access.c 9 | dwarf_error.c 10 | dwarf_form.c 11 | dwarf_frame.c 12 | dwarf_frame2.c 13 | dwarf_frame3.c 14 | dwarf_funcs.c 15 | dwarf_gdbindex.c 16 | dwarf_global.c 17 | dwarf_harmless.c 18 | dwarf_init_finish.c 19 | dwarf_leb.c 20 | dwarf_line.c 21 | dwarf_line2.c 22 | dwarf_loc.c 23 | dwarf_macro.c 24 | dwarf_names.c 25 | dwarf_original_elf_init.c 26 | dwarf_print_lines.c 27 | dwarf_pubtypes.c 28 | dwarf_query.c 29 | dwarf_ranges.c 30 | dwarf_sort_line.c 31 | dwarf_string.c 32 | dwarf_stubs.c 33 | dwarf_tsearchhash.c 34 | dwarf_types.c 35 | dwarf_util.c 36 | dwarf_vars.c 37 | dwarf_weaks.c 38 | dwarf_xu_index.c 39 | dwgetopt.c 40 | malloc_check.c 41 | pro_alloc.c 42 | pro_arange.c 43 | pro_die.c 44 | pro_encode_nm.c 45 | pro_error.c 46 | pro_expr.c 47 | pro_finish.c 48 | pro_forms.c 49 | pro_frame.c 50 | pro_funcs.c 51 | pro_init.c 52 | pro_line.c 53 | pro_macinfo.c 54 | pro_pubnames.c 55 | pro_reloc.c 56 | pro_reloc_stream.c 57 | pro_reloc_symbolic.c 58 | pro_section.c 59 | pro_types.c 60 | pro_vars.c 61 | pro_weaks.c 62 | ) 63 | 64 | add_library(libdwarf SHARED ${LIBDWARF_SOURCES}) 65 | set_target_properties(libdwarf PROPERTIES OUTPUT_NAME "retdec-libdwarf") 66 | target_link_libraries(libdwarf libelf) 67 | target_include_directories(libdwarf SYSTEM PUBLIC ${PROJECT_SOURCE_DIR} .) 68 | if(MSVC) 69 | set_target_properties(libdwarf PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) 70 | endif() 71 | install(TARGETS libdwarf 72 | LIBRARY DESTINATION lib 73 | RUNTIME DESTINATION bin 74 | ) 75 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | The files: 4 | libdwarf.h 5 | dwarf.h 6 | and all the .h and .c files in this implementation of 7 | libdwarf are copyrighted according to the file 8 | LIBDWARFCOPYRIGHT (which mentions the LGPL version 2.1). 9 | Each file mentions the LGPL. 10 | The full text of the LGPL 2.1 is provided in LGPL.txt 11 | 12 | The libdwarf documentation: 13 | libdwarf2.1.mm 14 | is based on material submitted to the UI PLSIG as proposed 15 | interfaces for dwarf, but completely rewritten. 16 | Copyright ownership is therefore SGI (but see the document for details) 17 | and it seems clear that the intent was there was to be free 18 | copying with no fees. 19 | 20 | libdwarf2p.1.mm 21 | is documentation of a set of interfaces 22 | (not part of the UI PLSIG proposals) 23 | and the document was written from scratch at SGI. 24 | Copyright ownership is therefore SGI (but see the document for details) 25 | and it seems clear that the intent was there was to be free 26 | copying with no fees. 27 | 28 | 17 March 2014:Updated to remove reference to dwarf.v2.mm. 29 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/LIBDWARFCOPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | 3 | ====== 4 | Update January 31, 2015: 5 | The SGI postal address and oss.sgi.com address 6 | in the original copyright are no longer correct. 7 | So the final 8 lines of the original copyright 8 | have been deleted from the current copyright. 9 | 10 | ====== original copyright example. 11 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 12 | 13 | This program is free software; you can redistribute it and/or modify it 14 | under the terms of version 2.1 of the GNU Lesser General Public License 15 | as published by the Free Software Foundation. 16 | 17 | This program is distributed in the hope that it would be useful, but 18 | WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | 21 | Further, this software is distributed without any warranty that it is 22 | free of the rightful claim of any third person regarding infringement 23 | or the like. Any license provided herein, whether implied or 24 | otherwise, applies only to this software file. Patent licenses, if 25 | any, provided herein do not apply to combinations of this program with 26 | other software, or any other product whatsoever. 27 | 28 | You should have received a copy of the GNU Lesser General Public 29 | License along with this program; if not, write the Free Software 30 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 31 | USA. 32 | 33 | Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, 34 | Mountain View, CA 94043, or: 35 | 36 | http://www.sgi.com 37 | 38 | For further information regarding this notice, see: 39 | 40 | http://oss.sgi.com/projects/GenInfo/NoticeExplan 41 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/cmplrs/dwarf_addr_finder.h: -------------------------------------------------------------------------------- 1 | /* 2 | dwarf_addr_finder.h 3 | $Source: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/include/cmplrs/RCS/dwarf_addr_finder.h,v $ 4 | $Date: 2002/06/11 17:49:06 $ 5 | 6 | Defines user interface. 7 | 8 | */ 9 | 10 | /* return codes for functions 11 | */ 12 | #define DW_DLV_NO_ENTRY -1 13 | #define DW_DLV_OK 0 14 | #define DW_DLV_ERROR 1 15 | 16 | 17 | /* the following are the 'section' number passed to the called-back 18 | function. 19 | The called-back application must translate this to the 20 | appropriate elf section number/pointer. 21 | 22 | Putting this burden on the application avoids having to store 23 | the numbers in the Dwarf_Debug structure (thereby saving space 24 | for most consumers). 25 | */ 26 | #define DW_SECTION_INFO 0 27 | #define DW_SECTION_FRAME 1 28 | #define DW_SECTION_ARANGES 2 29 | #define DW_SECTION_LINE 3 30 | #define DW_SECTION_LOC 4 /* .debug_loc */ 31 | 32 | /* section is one of the above codes: it specifies a section. 33 | secoff is the offset in the dwarf section. 34 | existingAddr is the value at the specified offset (so the 35 | called back routine can sanity check the proceedings). 36 | It's up to the caller to know the size of an address (4 or 8) 37 | and update the right number of bytes. 38 | */ 39 | typedef int (*Dwarf_addr_callback_func) (int /*section*/, 40 | Dwarf_Off /*secoff*/, Dwarf_Addr /*existingAddr*/); 41 | 42 | /* call this to do the work: it calls back thru cb_func 43 | once per each address to be modified. 44 | Once this returns you are done. 45 | Returns DW_DLV_OK if finished ok. 46 | Returns DW_DLV_ERROR if there was some kind of error, in which 47 | the dwarf error number was passed back thu the dwerr ptr. 48 | Returns DW_DLV_NO_ENTRY if there are no relevant dwarf sections, 49 | so there were no addresses to be modified (and none 50 | called back). 51 | */ 52 | int _dwarf_addr_finder(dwarf_elf_handle elf_file_ptr, 53 | Dwarf_addr_callback_func cb_func, 54 | int *dwerr); 55 | 56 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2008-2010 SN Systems. All Rights Reserved. 3 | Portions Copyright (C) 2008-2010 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | #include "common.h" 28 | 29 | void 30 | print_version(const char * name) 31 | { 32 | #ifdef _DEBUG 33 | const char *acType = "Debug"; 34 | #else 35 | const char *acType = "Release"; 36 | #endif /* _DEBUG */ 37 | 38 | char acVersion[60]; 39 | snprintf(acVersion,sizeof(acVersion),"[%s %s %s]", 40 | __DATE__,__TIME__,acType); 41 | printf("%s %s\n",name,acVersion); 42 | } 43 | 44 | void 45 | print_args(int argc, char *argv[]) 46 | { 47 | int index; 48 | printf("Arguments: "); 49 | for (index = 1; index < argc; ++index) { 50 | printf("%s ",argv[index]); 51 | } 52 | printf("\n"); 53 | } 54 | 55 | void 56 | print_usage_message(const char *options[]) 57 | { 58 | int index; 59 | for (index = 0; *options[index]; ++index) { 60 | printf("%s\n",options[index]); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009-2010 SN Systems. All Rights Reserved. 3 | Portions Copyright (C) 2009-2010 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #ifndef common_INCLUDED 29 | #define common_INCLUDED 30 | 31 | #include 32 | 33 | 34 | void print_args(int argc, char *argv[]); 35 | void print_usage_message(const char *options[]); 36 | void print_version(const char * name); 37 | 38 | #endif /* common_INCLUDED */ 39 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_abbrev.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright (C) 2008-2011 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | /* In a given CU, one of these is (eventually) set up 31 | for every abbreviation we need to find (and for all. 32 | those ealier in the abbreviations for that CU). 33 | So we don't want elements needlessly big. 34 | */ 35 | struct Dwarf_Abbrev_s { 36 | /* No TAG should exceed DW_TAG_hi_user, 0xffff, but 37 | we do allow a larger value here. */ 38 | Dwarf_Word ab_tag; 39 | /* Abbreviations are numbered (normally sequentially from 40 | 1 and so 16 bits is not enough! */ 41 | Dwarf_Word ab_code; 42 | Dwarf_Small ab_has_child; 43 | Dwarf_Byte_Ptr ab_abbrev_ptr; 44 | Dwarf_Debug ab_dbg; 45 | }; 46 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000,2005 Silicon Graphics, Inc. All Rights Reserved. 3 | Portions Copyright (C) 2008-2011 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | /* #define DWARF_SIMPLE_MALLOC 1 */ 28 | 29 | char * _dwarf_get_alloc(Dwarf_Debug, Dwarf_Small, Dwarf_Unsigned); 30 | Dwarf_Debug _dwarf_get_debug(void); 31 | int _dwarf_free_all_of_one_debug(Dwarf_Debug); 32 | struct Dwarf_Error_s * _dwarf_special_no_dbg_error_malloc(void); 33 | 34 | 35 | /* ALLOC_AREA_INDEX_TABLE_MAX is the size of the 36 | struct ial_s index_into_allocated array in dwarf_alloc.c 37 | */ 38 | #define ALLOC_AREA_INDEX_TABLE_MAX 57 39 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_arange.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright (C) 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | 29 | 30 | /* This structure is used to read an arange into. */ 31 | struct Dwarf_Arange_s { 32 | 33 | /* The segment selector. Only non-zero if Dwarf4, only 34 | meaningful if ar_segment_selector_size non-zero */ 35 | Dwarf_Unsigned ar_segment_selector; 36 | 37 | /* Starting address of the arange, ie low-pc. */ 38 | Dwarf_Addr ar_address; 39 | 40 | /* Length of the arange. */ 41 | Dwarf_Unsigned ar_length; 42 | 43 | 44 | /* Offset into .debug_info of the start of the compilation-unit 45 | containing this set of aranges. 46 | Applies only to .debug_info, not .debug_types. */ 47 | Dwarf_Off ar_info_offset; 48 | 49 | /* Corresponding Dwarf_Debug. */ 50 | Dwarf_Debug ar_dbg; 51 | 52 | Dwarf_Half ar_segment_selector_size; 53 | }; 54 | 55 | 56 | 57 | int 58 | _dwarf_get_aranges_addr_offsets(Dwarf_Debug dbg, 59 | Dwarf_Addr ** addrs, 60 | Dwarf_Off ** offsets, 61 | Dwarf_Signed * count, 62 | Dwarf_Error * error); 63 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_die_deliv.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright (C) 2008-2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | 29 | 30 | 31 | /* 32 | This struct holds information about a abbreviation. 33 | It is put in the hash table for abbreviations for 34 | a compile-unit. 35 | */ 36 | struct Dwarf_Abbrev_List_s { 37 | Dwarf_Unsigned ab_code; 38 | Dwarf_Half ab_tag; 39 | Dwarf_Half ab_has_child; 40 | 41 | /* Points to start of attribute and form pairs in the .debug_abbrev 42 | section for the abbrev. */ 43 | Dwarf_Byte_Ptr ab_abbrev_ptr; 44 | 45 | struct Dwarf_Abbrev_List_s *ab_next; 46 | }; 47 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_elf_access.h: -------------------------------------------------------------------------------- 1 | #ifndef _DWARF_ELF_PORT_H 2 | #define _DWARF_ELF_PORT_H 3 | /* 4 | 5 | Copyright (C) 2008-2011 David Anderson. All rights reserved. 6 | Portions Copyright 2008-2010 Arxan Technologies, Inc. All rights reserved. 7 | 8 | This program is free software; you can redistribute it and/or modify it 9 | under the terms of version 2.1 of the GNU Lesser General Public License 10 | as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it would be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | 16 | Further, this software is distributed without any warranty that it is 17 | free of the rightful claim of any third person regarding infringement 18 | or the like. Any license provided herein, whether implied or 19 | otherwise, applies only to this software file. Patent licenses, if 20 | any, provided herein do not apply to combinations of this program with 21 | other software, or any other product whatsoever. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with this program; if not, write the Free Software 25 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 26 | USA. 27 | 28 | */ 29 | 30 | 31 | 32 | /* ELF (usually libelf) object access for the generic object file interface */ 33 | 34 | int 35 | dwarf_elf_object_access_init(dwarf_elf_handle elf , 36 | int libdwarf_owns_elf, 37 | Dwarf_Obj_Access_Interface** ret_obj, 38 | int *err ); 39 | 40 | void 41 | dwarf_elf_object_access_finish(Dwarf_Obj_Access_Interface* obj ); 42 | 43 | /* End ELF object access for the generic object file interface */ 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright (C) 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | 29 | 30 | void _dwarf_error(Dwarf_Debug dbg, Dwarf_Error * error, 31 | Dwarf_Sword errval); 32 | 33 | struct Dwarf_Error_s { 34 | Dwarf_Sword er_errval; 35 | 36 | /* If non-zero the Dwarf_Error_s struct is not malloc'd. 37 | To aid when malloc returns NULL. 38 | If zero a normal dwarf_dealloc will work. 39 | er_static_alloc only accessed by dwarf_alloc.c. 40 | 41 | If er_static_alloc is 1 in a Dwarf_Error_s 42 | struct (set by libdwarf) and client code accidentally 43 | turns that 0 to zero through a wild 44 | pointer reference (the field is hidden 45 | from clients...) then chaos will 46 | eventually follow. 47 | */ 48 | int er_static_alloc; 49 | }; 50 | 51 | extern struct Dwarf_Error_s _dwarf_failsafe_error; 52 | 53 | 54 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000, 2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | typedef struct Dwarf_Func_Context_s *Dwarf_Func_Context; 31 | 32 | 33 | /* struct never completed: see dwarf_global.h */ 34 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_harmless.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 David Anderson. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | void dwarf_harmless_init(struct Dwarf_Harmless_s *dhp,unsigned size); 30 | void dwarf_harmless_cleanout(struct Dwarf_Harmless_s *dhp); 31 | 32 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_incl.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000, 2002, 2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2008-2010 David Anderson. All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | 29 | 30 | #ifndef DWARF_INCL_H 31 | #define DWARF_INCL_H 32 | #if (!defined(HAVE_RAW_LIBELF_OK) && defined(HAVE_LIBELF_OFF64_OK) ) 33 | /* At a certain point libelf.h requires _GNU_SOURCE. 34 | here we assume the criteria in configure determine that 35 | usefully. 36 | */ 37 | #define _GNU_SOURCE 1 38 | #endif 39 | 40 | #ifdef HAVE_STDAFX_H /* Windows specific. */ 41 | #include "stdafx.h" 42 | #endif /* HAVE_STDAFX_H */ 43 | 44 | #include "libdwarfdefs.h" 45 | #include 46 | 47 | #ifdef HAVE_ELF_H 48 | #include 49 | #endif 50 | 51 | #include 52 | #include 53 | #include 54 | 55 | #include "dwarf_base_types.h" 56 | #include "dwarf_alloc.h" 57 | #include "dwarf_xu_index.h" 58 | #include "dwarf_opaque.h" 59 | #include "dwarf_error.h" 60 | #include "dwarf_util.h" 61 | #endif /* DWARF_INCL_H */ 62 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_loc.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000, 2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | typedef struct Dwarf_Loc_Chain_s *Dwarf_Loc_Chain; 30 | 31 | struct Dwarf_Loc_Chain_s { 32 | Dwarf_Small lc_atom; 33 | Dwarf_Unsigned lc_number; 34 | Dwarf_Unsigned lc_number2; 35 | Dwarf_Unsigned lc_offset; 36 | Dwarf_Loc_Chain lc_next; 37 | }; 38 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_macro.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000, 2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | /* 29 | 30 | 31 | dwarf_macro.h 32 | 33 | $Revision: 1.4 $ $Date: 2004/10/28 22:19:14 $ 34 | 35 | */ 36 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_names_new.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated, do not edit. */ 2 | /* Generated on Aug 11 2015 15:43:46 */ 3 | 4 | /* BEGIN FILE */ 5 | 6 | /* define DWARF_PRINT_PREFIX before this 7 | point if you wish to. */ 8 | #ifndef DWARF_PRINT_PREFIX 9 | #define DWARF_PRINT_PREFIX dwarf_ 10 | #endif 11 | #define dw_glue(x,y) x##y 12 | #define dw_glue2(x,y) dw_glue(x,y) 13 | #define DWPREFIX(x) dw_glue2(DWARF_PRINT_PREFIX,x) 14 | int DWPREFIX(get_TAG_name) (unsigned int, const char **); 15 | int DWPREFIX(get_children_name) (unsigned int, const char **); 16 | int DWPREFIX(get_FORM_name) (unsigned int, const char **); 17 | int DWPREFIX(get_AT_name) (unsigned int, const char **); 18 | int DWPREFIX(get_OP_name) (unsigned int, const char **); 19 | int DWPREFIX(get_ATE_name) (unsigned int, const char **); 20 | int DWPREFIX(get_DEFAULTED_name) (unsigned int, const char **); 21 | int DWPREFIX(get_IDX_name) (unsigned int, const char **); 22 | int DWPREFIX(get_LLE_name) (unsigned int, const char **); 23 | int DWPREFIX(get_UT_name) (unsigned int, const char **); 24 | int DWPREFIX(get_SECT_name) (unsigned int, const char **); 25 | int DWPREFIX(get_DS_name) (unsigned int, const char **); 26 | int DWPREFIX(get_END_name) (unsigned int, const char **); 27 | int DWPREFIX(get_ATCF_name) (unsigned int, const char **); 28 | int DWPREFIX(get_ACCESS_name) (unsigned int, const char **); 29 | int DWPREFIX(get_VIS_name) (unsigned int, const char **); 30 | int DWPREFIX(get_VIRTUALITY_name) (unsigned int, const char **); 31 | int DWPREFIX(get_LANG_name) (unsigned int, const char **); 32 | int DWPREFIX(get_LNCT_name) (unsigned int, const char **); 33 | int DWPREFIX(get_ID_name) (unsigned int, const char **); 34 | int DWPREFIX(get_CC_name) (unsigned int, const char **); 35 | int DWPREFIX(get_INL_name) (unsigned int, const char **); 36 | int DWPREFIX(get_ORD_name) (unsigned int, const char **); 37 | int DWPREFIX(get_DSC_name) (unsigned int, const char **); 38 | int DWPREFIX(get_LNS_name) (unsigned int, const char **); 39 | int DWPREFIX(get_LNE_name) (unsigned int, const char **); 40 | int DWPREFIX(get_ISA_name) (unsigned int, const char **); 41 | int DWPREFIX(get_MACRO_name) (unsigned int, const char **); 42 | int DWPREFIX(get_MACINFO_name) (unsigned int, const char **); 43 | int DWPREFIX(get_CFA_name) (unsigned int, const char **); 44 | int DWPREFIX(get_EH_name) (unsigned int, const char **); 45 | int DWPREFIX(get_FRAME_name) (unsigned int, const char **); 46 | int DWPREFIX(get_CHILDREN_name) (unsigned int, const char **); 47 | int DWPREFIX(get_ADDR_name) (unsigned int, const char **); 48 | 49 | /* END FILE */ 50 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_string.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "dwarf_incl.h" 30 | 31 | int 32 | dwarf_get_str(Dwarf_Debug dbg, 33 | Dwarf_Off offset, 34 | char **string, 35 | Dwarf_Signed * returned_str_len, Dwarf_Error * error) 36 | { 37 | int res = DW_DLV_ERROR; 38 | 39 | if (dbg == NULL) { 40 | _dwarf_error(NULL, error, DW_DLE_DBG_NULL); 41 | return (DW_DLV_ERROR); 42 | } 43 | 44 | if (offset == dbg->de_debug_str.dss_size) { 45 | /* Normal (if we've iterated thru the set of strings using 46 | dwarf_get_str and are at the end). */ 47 | return DW_DLV_NO_ENTRY; 48 | } 49 | if (offset > dbg->de_debug_str.dss_size) { 50 | _dwarf_error(dbg, error, DW_DLE_DEBUG_STR_OFFSET_BAD); 51 | return (DW_DLV_ERROR); 52 | } 53 | 54 | if (string == NULL) { 55 | _dwarf_error(dbg, error, DW_DLE_STRING_PTR_NULL); 56 | return (DW_DLV_ERROR); 57 | } 58 | 59 | res = _dwarf_load_section(dbg, &dbg->de_debug_str,error); 60 | if (res != DW_DLV_OK) { 61 | return res; 62 | } 63 | if (!dbg->de_debug_str.dss_size) { 64 | return (DW_DLV_NO_ENTRY); 65 | } 66 | 67 | 68 | *string = (char *) dbg->de_debug_str.dss_data + offset; 69 | 70 | *returned_str_len = (strlen(*string)); 71 | return DW_DLV_OK; 72 | } 73 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "dwarf_incl.h" 30 | #include 31 | 32 | /*ARGSUSED*/ int 33 | dwarf_nextglob(Dwarf_Debug dbg, 34 | Dwarf_Global glob, 35 | Dwarf_Global * returned_nextglob, Dwarf_Error * error) 36 | { 37 | return (DW_DLV_NO_ENTRY); 38 | } 39 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | typedef struct Dwarf_Type_Context_s *Dwarf_Type_Context; 31 | 32 | /* type never completed see dwarf_global.h */ 33 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_vars.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | typedef struct Dwarf_Var_Context_s *Dwarf_Var_Context; 28 | 29 | /* struct never completed: see dwarf_global.h */ 30 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_weaks.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | typedef struct Dwarf_Weak_Context_s *Dwarf_Weak_Context; 28 | 29 | /* struct never completed: see dwarf_global.h */ 30 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwarf_xu_index.h: -------------------------------------------------------------------------------- 1 | #ifndef DWARF_XU_INDEX_H 2 | #define DWARF_XU_INDEX_H 3 | /* 4 | 5 | Copyright (C) 2014-2014 David Anderson. All Rights Reserved. 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of version 2.1 of the GNU Lesser General Public License 9 | as published by the Free Software Foundation. 10 | 11 | This program is distributed in the hope that it would be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | Further, this software is distributed without any warranty that it is 16 | free of the rightful claim of any third person regarding infringement 17 | or the like. Any license provided herein, whether implied or 18 | otherwise, applies only to this software file. Patent licenses, if 19 | any, provided herein do not apply to combinations of this program with 20 | other software, or any other product whatsoever. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this program; if not, write the Free Software 24 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 25 | USA. 26 | 27 | 28 | */ 29 | 30 | 31 | 32 | /* The following is based on 33 | The gdb online documentation at 34 | https://gcc.gnu.org/wiki/DebugFissionDWP 35 | and the draft DWARF5 standard. 36 | */ 37 | 38 | 39 | struct Dwarf_Xu_Index_Header_s { 40 | Dwarf_Debug gx_dbg; 41 | Dwarf_Small * gx_section_data; 42 | Dwarf_Unsigned gx_section_length; 43 | 44 | Dwarf_Unsigned gx_version; 45 | Dwarf_Unsigned gx_column_count_sections; /* L */ 46 | Dwarf_Unsigned gx_units_in_index; /* N */ 47 | Dwarf_Unsigned gx_slots_in_hash; /* M */ 48 | Dwarf_Unsigned gx_hash_table_offset; 49 | Dwarf_Unsigned gx_index_table_offset; 50 | Dwarf_Unsigned gx_section_offsets_offset; 51 | Dwarf_Unsigned gx_section_sizes_offset; 52 | 53 | /* "tu" or "cu" without the quotes, of course. NUL terminated. */ 54 | char gx_type[4]; 55 | 56 | /* Do not free gx_section_name. */ 57 | const char * gx_section_name; 58 | }; 59 | 60 | #endif /* DWARF_XU_INDEX_H */ 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/dwgetopt.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: getopt.c,v 1.1 2009/03/22 22:33:13 joerg Exp $*/ 2 | /* Modified by David Anderson to work with GNU/Linux and freebsd. 3 | Added {} for clarity. 4 | Switched to standard dwarfdump formatting. 5 | Treatment of : modified so that :: gets optarg NULL 6 | if space follows the letter 7 | (the optarg is set to null). 8 | */ 9 | /* 10 | * Copyright (c) 1987, 1993, 1994 11 | * The Regents of the University of California. All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 3. Neither the name of the University nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 | * SUCH DAMAGE. 36 | */ 37 | 38 | extern int libdwarf_opterr; 39 | extern int libdwarf_optind; 40 | extern int libdwarf_optopt; 41 | extern int optreset; 42 | extern char *optarg; 43 | 44 | int dwgetopt(int nargc, char * const nargv[], const char *ostr); 45 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/gennames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/libdwarf/gennames -------------------------------------------------------------------------------- /libdwarf/libdwarf/libdwarf.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/libdwarf/libdwarf.a -------------------------------------------------------------------------------- /libdwarf/libdwarf/libdwarf2.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/libdwarf/libdwarf2.1.pdf -------------------------------------------------------------------------------- /libdwarf/libdwarf/libdwarf2p.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/libdwarf/libdwarf2p.1.pdf -------------------------------------------------------------------------------- /libdwarf/libdwarf/malloc_check.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms of version 2.1 of the GNU Lesser General Public License 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it would be useful, but 9 | WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | Further, this software is distributed without any warranty that it is 13 | free of the rightful claim of any third person regarding infringement 14 | or the like. Any license provided herein, whether implied or 15 | otherwise, applies only to this software file. Patent licenses, if 16 | any, provided herein do not apply to combinations of this program with 17 | other software, or any other product whatsoever. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, write the Free Software 21 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 22 | USA. 23 | 24 | */ 25 | 26 | /* malloc_check.h */ 27 | 28 | /* A simple libdwarf-aware malloc checker. 29 | define WANT_LIBBDWARF_MALLOC_CHECK and rebuild libdwarf 30 | do make a checking-for-alloc-mistakes libdwarf. 31 | NOT recommended for production use. 32 | 33 | When defined, also add malloc_check.c to the list of 34 | files in Makefile. 35 | */ 36 | 37 | #undef WANT_LIBBDWARF_MALLOC_CHECK 38 | /*#define WANT_LIBBDWARF_MALLOC_CHECK 1 */ 39 | 40 | #ifdef WANT_LIBBDWARF_MALLOC_CHECK 41 | 42 | void dwarf_malloc_check_alloc_data(void * addr,unsigned char code); 43 | void dwarf_malloc_check_dealloc_data(void * addr,unsigned char code); 44 | void dwarf_malloc_check_complete(char *wheremsg); /* called at exit of app */ 45 | 46 | #else /* !WANT_LIBBDWARF_MALLOC_CHECK */ 47 | 48 | #define dwarf_malloc_check_alloc_data(a,b) /* nothing */ 49 | #define dwarf_malloc_check_dealloc_data(a,b) /* nothing */ 50 | #define dwarf_malloc_check_complete(a) /* nothing */ 51 | 52 | #endif /* WANT_LIBBDWARF_MALLOC_CHECK */ 53 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/mips_extensions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/libdwarf/mips_extensions.pdf -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | Dwarf_Ptr _dwarf_p_get_alloc(Dwarf_P_Debug, Dwarf_Unsigned); 30 | 31 | void _dwarf_p_dealloc(Dwarf_P_Debug dbg, Dwarf_Small * ptr); 32 | 33 | void _dwarf_p_dealloc_all(Dwarf_P_Debug dbg); 34 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_arange.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | /* 29 | If ag_end_symbol_index is zero, 30 | ag_length must be known and non-zero. 31 | 32 | Deals with length being known costant or fr 33 | assembler output, not known. 34 | */ 35 | 36 | struct Dwarf_P_Arange_s { 37 | Dwarf_Addr ag_begin_address; /* known address or for 38 | symbolic assem output, 39 | offset of symbol */ 40 | Dwarf_Addr ag_length; /* zero or address or offset */ 41 | Dwarf_Unsigned ag_symbol_index; 42 | 43 | Dwarf_P_Arange ag_next; 44 | 45 | Dwarf_Unsigned ag_end_symbol_index; /* zero or index/id of end 46 | symbol */ 47 | Dwarf_Addr ag_end_symbol_offset; /* known address or for 48 | symbolic assem output, 49 | offset of end symbol */ 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_die.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | /* 31 | This struct holds the abbreviation table, before they are written 32 | on disk. Holds a linked list of abbreviations, each consisting of 33 | a bitmap for attributes and a bitmap for forms 34 | */ 35 | typedef struct Dwarf_P_Abbrev_s *Dwarf_P_Abbrev; 36 | 37 | struct Dwarf_P_Abbrev_s { 38 | Dwarf_Unsigned abb_idx; /* index of abbreviation */ 39 | Dwarf_Tag abb_tag; /* tag of die */ 40 | Dwarf_Ubyte abb_children; /* if children are present */ 41 | Dwarf_ufixed *abb_attrs; /* holds names of attrs */ 42 | Dwarf_ufixed *abb_forms; /* forms of attributes */ 43 | int abb_n_attr; /* num of attrs = # of forms */ 44 | Dwarf_P_Abbrev abb_next; 45 | }; 46 | 47 | /* used in pro_section.c */ 48 | 49 | int _dwarf_pro_add_AT_fde(Dwarf_P_Debug dbg, Dwarf_P_Die die, 50 | Dwarf_Unsigned offset, Dwarf_Error * error); 51 | 52 | int _dwarf_pro_add_AT_stmt_list(Dwarf_P_Debug dbg, 53 | Dwarf_P_Die first_die, 54 | Dwarf_Error * error); 55 | 56 | int _dwarf_pro_add_AT_macro_info(Dwarf_P_Debug dbg, 57 | Dwarf_P_Die first_die, 58 | Dwarf_Unsigned offset, 59 | Dwarf_Error * error); 60 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_encode_nm.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | /* Bytes needed to encode a number. 30 | Not a tight bound, just a reasonable bound. 31 | */ 32 | #define ENCODE_SPACE_NEEDED (2*sizeof(Dwarf_Unsigned)) 33 | 34 | 35 | int _dwarf_pro_encode_leb128_nm(Dwarf_Unsigned val, int *nbytes, 36 | char *space, int splen); 37 | 38 | int _dwarf_pro_encode_signed_leb128_nm(Dwarf_Signed value, int *nbytes, 39 | char *space, int splen); 40 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | /* Handle error passing in the name of the Dwarf_P_Debug 31 | User must supply {} around the macro. 32 | Putting the {} here leads to macro uses that don't look like C. 33 | The error argument to dwarf_error is hard coded here as 'error' 34 | */ 35 | #define DWARF_P_DBG_ERROR(dbg,errval,retval) \ 36 | _dwarf_p_error(dbg,error,errval); return(retval); 37 | 38 | struct Dwarf_Error_s { 39 | Dwarf_Sword er_errval; 40 | }; 41 | 42 | void _dwarf_p_error(Dwarf_P_Debug dbg, Dwarf_Error * error, 43 | Dwarf_Word errval); 44 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | #define MAXIMUM_LOC_EXPR_LENGTH 20 29 | 30 | struct Dwarf_P_Expr_s { 31 | Dwarf_Small ex_byte_stream[MAXIMUM_LOC_EXPR_LENGTH]; 32 | Dwarf_P_Debug ex_dbg; 33 | Dwarf_Unsigned ex_next_byte_offset; 34 | Dwarf_Unsigned ex_reloc_sym_index; 35 | Dwarf_Unsigned ex_reloc_offset; 36 | }; 37 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_finish.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved. 5 | Portions Copyright 2011 David Anderson. All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of version 2.1 of the GNU Lesser General Public License 9 | as published by the Free Software Foundation. 10 | 11 | This program is distributed in the hope that it would be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | Further, this software is distributed without any warranty that it is 16 | free of the rightful claim of any third person regarding infringement 17 | or the like. Any license provided herein, whether implied or 18 | otherwise, applies only to this software file. Patent licenses, if 19 | any, provided herein do not apply to combinations of this program with 20 | other software, or any other product whatsoever. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this program; if not, write the Free Software 24 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 25 | USA. 26 | 27 | */ 28 | 29 | #include "config.h" 30 | #include "libdwarfdefs.h" 31 | #include "pro_incl.h" 32 | 33 | /* This routine deallocates all memory, and does some 34 | finishing up */ 35 | /*ARGSUSED*/ Dwarf_Unsigned 36 | dwarf_producer_finish(Dwarf_P_Debug dbg, Dwarf_Error * error) 37 | { 38 | if (dbg->de_version_magic_number != PRO_VERSION_MAGIC) { 39 | DWARF_P_DBG_ERROR(dbg, DW_DLE_IA, DW_DLV_NOCOUNT); 40 | } 41 | 42 | /* this frees all blocks, then frees dbg. */ 43 | _dwarf_p_dealloc_all(dbg); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_funcs.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "libdwarfdefs.h" 30 | #include 31 | #include 32 | #ifdef HAVE_ELFACCESS_H 33 | #include 34 | #endif 35 | #include "pro_incl.h" 36 | #include "pro_section.h" 37 | 38 | /* This function adds another function name to the 39 | list of function names for the given Dwarf_P_Debug. 40 | It returns 0 on error, and 1 otherwise. */ 41 | Dwarf_Unsigned 42 | dwarf_add_funcname(Dwarf_P_Debug dbg, 43 | Dwarf_P_Die die, 44 | char *function_name, Dwarf_Error * error) 45 | { 46 | return 47 | _dwarf_add_simple_name_entry(dbg, die, function_name, 48 | dwarf_snk_funcname, error); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_macinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | int _dwarf_pro_transform_macro_info_to_disk(Dwarf_P_Debug dbg, 31 | Dwarf_Error * error); 32 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_pubnames.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "libdwarfdefs.h" 30 | #include 31 | #include 32 | #ifdef HAVE_ELFACCESS_H 33 | #include 34 | #endif 35 | #include "pro_incl.h" 36 | #include "pro_section.h" 37 | 38 | 39 | /* This function adds another public name to the 40 | list of public names for the given Dwarf_P_Debug. 41 | It returns 0 on error, and 1 otherwise. */ 42 | 43 | Dwarf_Unsigned 44 | dwarf_add_pubname(Dwarf_P_Debug dbg, 45 | Dwarf_P_Die die, 46 | char *pubname_name, Dwarf_Error * error) 47 | { 48 | return 49 | _dwarf_add_simple_name_entry(dbg, die, pubname_name, 50 | dwarf_snk_pubname, error); 51 | } 52 | Dwarf_Unsigned 53 | dwarf_add_pubtype(Dwarf_P_Debug dbg, 54 | Dwarf_P_Die die, 55 | char *pubtype_name, Dwarf_Error * error) 56 | { 57 | return 58 | _dwarf_add_simple_name_entry(dbg, die, pubtype_name, 59 | dwarf_snk_pubtype, error); 60 | } 61 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_reloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | int _dwarf_pro_pre_alloc_n_reloc_slots(Dwarf_P_Debug dbg, 31 | int rel_sec_index, 32 | Dwarf_Unsigned newslots); 33 | 34 | int _dwarf_pro_alloc_reloc_slots(Dwarf_P_Debug dbg, int rel_sec_index); 35 | 36 | int _dwarf_pro_reloc_get_a_slot(Dwarf_P_Debug dbg, 37 | int base_sec_index, 38 | void **relrec_to_fill); 39 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_reloc_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | 29 | 30 | int _dwarf_pro_reloc_name_stream64(Dwarf_P_Debug dbg, 31 | int base_sec_index, 32 | Dwarf_Unsigned offset,/* r_offset of reloc */ 33 | Dwarf_Unsigned symidx, 34 | enum Dwarf_Rel_Type, 35 | int reltarget_length); 36 | int _dwarf_pro_reloc_name_stream32(Dwarf_P_Debug dbg, 37 | int base_sec_index, 38 | Dwarf_Unsigned offset,/* r_offset of reloc */ 39 | Dwarf_Unsigned symidx, 40 | enum Dwarf_Rel_Type, 41 | int reltarget_length); 42 | 43 | int _dwarf_pro_reloc_length_stream(Dwarf_P_Debug dbg, 44 | int base_sec_index, 45 | Dwarf_Unsigned offset, /* r_offset of reloc */ 46 | Dwarf_Unsigned start_symidx, 47 | Dwarf_Unsigned end_symidx, 48 | enum Dwarf_Rel_Type, 49 | int reltarget_length); 50 | 51 | int _dwarf_stream_relocs_to_disk(Dwarf_P_Debug dbg, 52 | Dwarf_Signed * new_sec_count); 53 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_reloc_symbolic.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | int _dwarf_pro_reloc_name_symbolic(Dwarf_P_Debug dbg, 29 | int base_sec_index, 30 | Dwarf_Unsigned offset,/* r_offset of reloc */ 31 | Dwarf_Unsigned symidx, 32 | enum Dwarf_Rel_Type, 33 | int reltarget_length); 34 | 35 | int 36 | _dwarf_pro_reloc_length_symbolic(Dwarf_P_Debug dbg, 37 | int base_sec_index, 38 | Dwarf_Unsigned offset, /* r_offset of reloc */ 39 | Dwarf_Unsigned start_symidx, 40 | Dwarf_Unsigned end_symidx, 41 | enum Dwarf_Rel_Type, 42 | int reltarget_length); 43 | 44 | int _dwarf_symbolic_relocs_to_disk(Dwarf_P_Debug dbg, 45 | Dwarf_Signed * new_sec_count); 46 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of version 2.1 of the GNU Lesser General Public License 7 | as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it would be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | Further, this software is distributed without any warranty that it is 14 | free of the rightful claim of any third person regarding infringement 15 | or the like. Any license provided herein, whether implied or 16 | otherwise, applies only to this software file. Patent licenses, if 17 | any, provided herein do not apply to combinations of this program with 18 | other software, or any other product whatsoever. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this program; if not, write the Free Software 22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 | USA. 24 | 25 | */ 26 | 27 | 28 | /* pro_types.h */ 29 | 30 | 31 | int _dwarf_transform_simplename_to_disk(Dwarf_P_Debug dbg, 32 | enum dwarf_sn_kind entrykind, 33 | int section_index,/* in de_elf_sects etc */ 34 | Dwarf_Error * error); 35 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2014-2014 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | /* Definition of sizes of types. Independent of 29 | target or host, these are. */ 30 | #define sizeof_sbyte(dbg) sizeof(Dwarf_Sbyte) 31 | #define sizeof_ubyte(dbg) sizeof(Dwarf_Ubyte) 32 | #define sizeof_uhalf(dbg) sizeof(Dwarf_Half) 33 | 34 | /* Computes amount of padding necessary to align n to a k-boundary. */ 35 | /* Important: Assumes n, k both GREATER than zero. */ 36 | #define PADDING(n, k) ( (k)-1 - ((n)-1)%(k) ) 37 | 38 | 39 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_vars.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "libdwarfdefs.h" 30 | #include 31 | #include 32 | #ifdef HAVE_ELFACCESS_H 33 | #include 34 | #endif 35 | #include "pro_incl.h" 36 | #include "pro_section.h" 37 | 38 | /* 39 | This function adds another variable name to the 40 | list of variable names for the given Dwarf_P_Debug. 41 | It returns 0 on error, and 1 otherwise. 42 | */ 43 | Dwarf_Unsigned 44 | dwarf_add_varname(Dwarf_P_Debug dbg, 45 | Dwarf_P_Die die, char *var_name, Dwarf_Error * error) 46 | { 47 | return 48 | _dwarf_add_simple_name_entry(dbg, die, var_name, 49 | dwarf_snk_varname, error); 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /libdwarf/libdwarf/pro_weaks.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 4 | Portions Copyright 2011 David Anderson. All Rights Reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of version 2.1 of the GNU Lesser General Public License 8 | as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope that it would be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | Further, this software is distributed without any warranty that it is 15 | free of the rightful claim of any third person regarding infringement 16 | or the like. Any license provided herein, whether implied or 17 | otherwise, applies only to this software file. Patent licenses, if 18 | any, provided herein do not apply to combinations of this program with 19 | other software, or any other product whatsoever. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this program; if not, write the Free Software 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 24 | USA. 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "libdwarfdefs.h" 30 | #include 31 | #include 32 | #ifdef HAVE_ELFACCESS_H 33 | #include 34 | #endif 35 | #include "pro_incl.h" 36 | #include "pro_section.h" 37 | 38 | /* 39 | This function adds another weak name to the 40 | list of weak names for the given Dwarf_P_Debug. 41 | It returns 0 on error, and 1 otherwise. 42 | */ 43 | Dwarf_Unsigned 44 | dwarf_add_weakname(Dwarf_P_Debug dbg, 45 | Dwarf_P_Die die, 46 | char *weak_name, Dwarf_Error * error) 47 | { 48 | return 49 | _dwarf_add_simple_name_entry(dbg, die, weak_name, 50 | dwarf_snk_weakname, error); 51 | } 52 | -------------------------------------------------------------------------------- /libdwarf/tsearch/ChangeLog: -------------------------------------------------------------------------------- 1 | 2015-01-01 David Anderson 2 | * A new year begins. 3 | 4 | -------------------------------------------------------------------------------- /libdwarf/tsearch/ChangeLog2014: -------------------------------------------------------------------------------- 1 | 2014-12-09: David Anderson 2 | * dwarf_tsearchhash.c(tsearch_inner): Add check for NULL 3 | so we do not just coredump if out of memory. 4 | * dwarf_tsearchred.c(tsearch_inner): Add check for NULL 5 | so we do not just coredump if out of memory. 6 | 2014-09-10: David Anderson 7 | * dwarf_tsearchhash.c(calculate_allowed_fill): Moved a declaration 8 | to avoid using C99 feature. 9 | 2014-08-04: David Anderson 10 | * dwarf_tsearchhash.c: Changed to avoid compiler warnings 11 | about const casts whereever possible. 12 | 2014-01-29: David Anderson 13 | * All files: All added. Trailing whitespace removed. 14 | -------------------------------------------------------------------------------- /libdwarf/tsearch/config.h: -------------------------------------------------------------------------------- 1 | 2 | /* Nothing here, really, a placeholder. */ 3 | -------------------------------------------------------------------------------- /libdwarf/tsearch/dwarf_incl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, David Anderson 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with 5 | or without modification, are permitted provided that the 6 | following conditions are met: 7 | 8 | Redistributions of source code must retain the above 9 | copyright notice, this list of conditions and the following 10 | disclaimer. 11 | 12 | Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials 15 | provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 18 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | #include 33 | #include "stdlib.h" /* for exit() */ 34 | -------------------------------------------------------------------------------- /libdwarf/tsearch/scripts/TEST.sh: -------------------------------------------------------------------------------- 1 | 2 | set -x 3 | python concatlines.py comparatorsample.new 4 | diff comparatorsample comparatorsample.new 5 | 6 | -------------------------------------------------------------------------------- /libdwarf/tsearch/scripts/badsample: -------------------------------------------------------------------------------- 1 | 2 | 0.00 856 === -s -v dwgenb/dwarfgen 3 | 0.00 760 === -ta -v dwgenb/dwarfgen 4 | 0.00 760 === -tf -v dwgenb/dwarfgen 5 | 0.00 752 === -y -v dwgenb/dwarfgen 6 | 0.00 756 === -w -v dwgenb/dwarfgen 7 | 0.00 936 === -N -v dwgenb/dwarfgen 8 | 0.00 1380 === -b -v -v dwgenb/dwarfgen 9 | 0.01 1208 === -c -v -v dwgenb/dwarfgen 10 | 0.00 792 === -f -v -v dwgenb/dwarfgen 11 | 1.13 2172 === -F -v -v dwgenb/dwarfgen 12 | -------------------------------------------------------------------------------- /libdwarf/tsearch/scripts/comparatorsample: -------------------------------------------------------------------------------- 1 | 2 | 0.00 856 === -s -v dwgenb/dwarfgen 3 | 0.00 760 === -ta -v dwgenb/dwarfgen 4 | 0.00 760 === -tf -v dwgenb/dwarfgen 5 | 0.00 760 === -tv -v dwgenb/dwarfgen 6 | 0.00 752 === -y -v dwgenb/dwarfgen 7 | 0.00 756 === -w -v dwgenb/dwarfgen 8 | 0.00 936 === -N -v dwgenb/dwarfgen 9 | 0.00 1380 === -b -v -v dwgenb/dwarfgen 10 | 0.01 1208 === -c -v -v dwgenb/dwarfgen 11 | 0.00 792 === -f -v -v dwgenb/dwarfgen 12 | 1.13 2172 === -F -v -v dwgenb/dwarfgen 13 | -------------------------------------------------------------------------------- /libdwarf/tsearch/scripts/concatlinesample: -------------------------------------------------------------------------------- 1 | === -s -v dwgenb/dwarfgen 2 | 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 856maxresident)k 3 | 0inputs+0outputs (0major+292minor)pagefaults 0swaps 4 | === -ta -v dwgenb/dwarfgen 5 | 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 760maxresident)k 6 | 0inputs+0outputs (0major+244minor)pagefaults 0swaps 7 | === -tf -v dwgenb/dwarfgen 8 | 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 760maxresident)k 9 | 0inputs+0outputs (0major+244minor)pagefaults 0swaps 10 | === -tv -v dwgenb/dwarfgen 11 | 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 760maxresident)k 12 | 0inputs+0outputs (0major+245minor)pagefaults 0swaps 13 | === -y -v dwgenb/dwarfgen 14 | 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 752maxresident)k 15 | 0inputs+0outputs (0major+242minor)pagefaults 0swaps 16 | === -w -v dwgenb/dwarfgen 17 | 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 756maxresident)k 18 | 0inputs+0outputs (0major+243minor)pagefaults 0swaps 19 | === -N -v dwgenb/dwarfgen 20 | 0.00user 0.00system 0:00.01elapsed 44%CPU (0avgtext+0avgdata 936maxresident)k 21 | 0inputs+0outputs (0major+288minor)pagefaults 0swaps 22 | === -b -v -v dwgenb/dwarfgen 23 | 0.00user 0.00system 0:00.01elapsed 47%CPU (0avgtext+0avgdata 1380maxresident)k 24 | 0inputs+0outputs (0major+467minor)pagefaults 0swaps 25 | === -c -v -v dwgenb/dwarfgen 26 | Command exited with non-zero status 1 27 | 0.01user 0.00system 0:00.03elapsed 62%CPU (0avgtext+0avgdata 1208maxresident)k 28 | 0inputs+0outputs (0major+355minor)pagefaults 0swaps 29 | === -f -v -v dwgenb/dwarfgen 30 | 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 792maxresident)k 31 | 0inputs+0outputs (0major+252minor)pagefaults 0swaps 32 | === -F -v -v dwgenb/dwarfgen 33 | 1.13user 0.00system 0:01.20elapsed 94%CPU (0avgtext+0avgdata 2172maxresident)k 34 | 0inputs+0outputs (0major+606minor)pagefaults 0swaps 35 | -------------------------------------------------------------------------------- /libdwarf/tsearch/scripts/secondsample: -------------------------------------------------------------------------------- 1 | 2 | 0.00 856 === -s -v dwgenb/dwarfgen 3 | 0.00 760 === -ta -v dwgenb/dwarfgen 4 | 0.00 760 === -tf -v dwgenb/dwarfgen 5 | 0.00 760 === -tv -v dwgenb/dwarfgen 6 | 0.00 752 === -y -v dwgenb/dwarfgen 7 | 0.00 756 === -w -v dwgenb/dwarfgen 8 | 0.00 936 === -N -v dwgenb/dwarfgen 9 | 0.00 1380 === -b -v -v dwgenb/dwarfgen 10 | 0.01 1208 === -c -v -v dwgenb/dwarfgen 11 | 0.00 792 === -f -v -v dwgenb/dwarfgen 12 | 1.13 2172 === -F -v -v dwgenb/dwarfgen 13 | -------------------------------------------------------------------------------- /libdwarf/tsearch/scripts/testin: -------------------------------------------------------------------------------- 1 | =======a 2 | b 3 | c 4 | d 5 | ========e 6 | f 7 | 8 | -------------------------------------------------------------------------------- /libdwarf/tsearch/tsearchlibtimes.csv: -------------------------------------------------------------------------------- 1 | lib,testcase,usertime,elapsed,maxmem 2 | Hash-bv,dd2g4,0.46,0.49,17640 3 | hash,dd2g4,0.6,0.68,17908 4 | Bal-bv,dd2g4,0.84,0.91,17328 5 | Red-bv,dd2g4,0.85,0.88,17296 6 | Gnu-bv,dd2g4,0.94,1,17296 7 | red,dd2g4,1,1.1,17560 8 | bal,dd2g4,1.02,1.14,17716 9 | gnu,dd2g4,1.14,1.24,17564 10 | Epp-bv,dd2g4,27.27,27.91,17032 11 | Bin-bv,dd2g4,28.8,28.91,17032 12 | epp,dd2g4,32.05,32.3,17564 13 | bin,dd2g4,33.8,33.84,17560 14 | Hash-bv,F-dwgenb,0.15,0.15,6164 15 | hash,F-dwgenb,0.18,0.26,6160 16 | Red-bv,F-dwgenb,0.19,0.22,6160 17 | Bal-bv,F-dwgenb,0.23,0.24,6160 18 | red,F-dwgenb,0.24,0.25,6160 19 | bal,F-dwgenb,0.28,0.3,6160 20 | Gnu-bv,F-dwgenb,0.28,0.32,6160 21 | gnu,F-dwgenb,0.34,0.35,6160 22 | Bin-bv,F-dwgenb,8.45,9.07,6164 23 | Epp-bv,F-dwgenb,8.51,9.17,6160 24 | bin,F-dwgenb,9.98,10.78,6160 25 | epp,F-dwgenb,10.3,10.84,6160 26 | Hash-bv,irix64,0.1,0.15,6028 27 | hash,irix64,0.17,0.17,6296 28 | Bal-bv,irix64,0.24,0.25,5688 29 | Gnu-bv,irix64,0.25,0.26,5688 30 | bal,irix64,0.3,0.32,5692 31 | Red-bv,irix64,0.31,0.36,5688 32 | gnu,irix64,0.32,0.37,5956 33 | red,irix64,0.36,0.37,5952 34 | Bin-bv,irix64,1.36,1.4,5428 35 | Epp-bv,irix64,1.36,1.37,5428 36 | bin,irix64,1.63,1.75,5692 37 | epp,irix64,1.64,1.78,5688 38 | Hash-bv,vvirix64,0.02,0.03,1988 39 | hash,vvirix64,0.04,0.04,2056 40 | Bal-bv,vvirix64,0.05,0.05,1796 41 | Red-bv,vvirix64,0.05,0.05,1760 42 | bal,vvirix64,0.06,0.07,1928 43 | red,vvirix64,0.06,0.06,2024 44 | Gnu-bv,vvirix64,0.06,0.06,1756 45 | gnu,vvirix64,0.07,0.07,2020 46 | Bin-bv,vvirix64,4.34,4.47,1500 47 | Epp-bv,vvirix64,4.4,4.43,1496 48 | epp,vvirix64,5.09,5.31,1760 49 | bin,vvirix64,5.19,5.54,1756 50 | -------------------------------------------------------------------------------- /libdwarf/tsearch/tsearchlibtimes.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libdwarf/tsearch/tsearchlibtimes.ods -------------------------------------------------------------------------------- /libelf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(lib) 2 | -------------------------------------------------------------------------------- /libelf/MANIFEST: -------------------------------------------------------------------------------- 1 | 25275 COPYING.LIB 2 | 35406 ChangeLog 3 | 7462 INSTALL 4 | 5908 Makefile.in 5 | 13232 README 6 | 7 VERSION 7 | 2955 acconfig.h 8 | 9381 aclocal.m4 9 | 43611 config.guess 10 | 3987 config.h.in 11 | 31160 config.sub 12 | 110753 configure 13 | 11736 configure.in 14 | 2186 install-sh 15 | 4798 lib/32.fsize.c 16 | 1556 lib/32.getehdr.c 17 | 1557 lib/32.getphdr.c 18 | 1665 lib/32.getshdr.c 19 | 2181 lib/32.newehdr.c 20 | 3055 lib/32.newphdr.c 21 | 12322 lib/32.xlatetof.c 22 | 14221 lib/64.xlatetof.c 23 | 8012 lib/Makefile.in 24 | 4010 lib/Makefile.w32 25 | 1119 lib/assert.c 26 | 10463 lib/begin.c 27 | 1685 lib/build.bat 28 | 3566 lib/byteswap.h 29 | 3937 lib/checksum.c 30 | 1901 lib/cntl.c 31 | 4851 lib/config.h.w32 32 | 12554 lib/cook.c 33 | 1183 lib/data.c 34 | 24585 lib/elf_repl.h 35 | 2899 lib/end.c 36 | 2137 lib/errmsg.c 37 | 1037 lib/errno.c 38 | 6222 lib/errors.h 39 | 8107 lib/ext_types.h 40 | 997 lib/fill.c 41 | 2400 lib/flag.c 42 | 5103 lib/gelf.h 43 | 4151 lib/gelfehdr.c 44 | 3965 lib/gelfphdr.c 45 | 3758 lib/gelfshdr.c 46 | 9456 lib/gelftrans.c 47 | 1175 lib/getarhdr.c 48 | 1380 lib/getaroff.c 49 | 2421 lib/getarsym.c 50 | 1096 lib/getbase.c 51 | 3841 lib/getdata.c 52 | 1353 lib/getident.c 53 | 1449 lib/getscn.c 54 | 1212 lib/hash.c 55 | 2562 lib/input.c 56 | 1088 lib/kind.c 57 | 1214 lib/libelf.def 58 | 9050 lib/libelf.h 59 | 1505 lib/memset.c 60 | 1098 lib/ndxscn.c 61 | 1558 lib/newdata.c 62 | 3488 lib/newscn.c 63 | 1356 lib/next.c 64 | 1607 lib/nextscn.c 65 | 5898 lib/nlist.c 66 | 1452 lib/nlist.h 67 | 5071 lib/opt.delscn.c 68 | 13133 lib/private.h 69 | 1286 lib/rand.c 70 | 2543 lib/rawdata.c 71 | 1541 lib/rawfile.c 72 | 3393 lib/strptr.c 73 | 2285 lib/swap64.c 74 | 3812 lib/sys_elf.h.in 75 | 4066 lib/sys_elf.h.w32 76 | 26008 lib/update.c 77 | 6884 lib/verdef.h 78 | 1586 lib/verdef_32_tof.c 79 | 1586 lib/verdef_32_tom.c 80 | 1614 lib/verdef_64_tof.c 81 | 1614 lib/verdef_64_tom.c 82 | 7135 lib/verneed.h 83 | 1435 lib/version.c 84 | 4425 lib/x.elfext.c 85 | 2721 lib/x.movscn.c 86 | 2870 lib/x.remscn.c 87 | 254 libelf.pc.in 88 | 619 mkinstalldirs 89 | 4593 po/Makefile.in 90 | 8748 po/de.gmo 91 | 52 po/de.msg 92 | 11332 po/de.po 93 | 3011 po/gmo2msg.c 94 | 6483 po/libelf.pot 95 | 10 po/stamp-po 96 | 10 stamp-h.in 97 | -------------------------------------------------------------------------------- /libelf/VERSION: -------------------------------------------------------------------------------- 1 | 0.8.13 2 | -------------------------------------------------------------------------------- /libelf/lib/32.getehdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | 32.getehdr.c - implementation of the elf{32,64}_getehdr(3) functions. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: 32.getehdr.c,v 1.9 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | char* 27 | _elf_getehdr(Elf *elf, unsigned cls) { 28 | if (!elf) { 29 | return NULL; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | if (elf->e_kind != ELF_K_ELF) { 33 | seterr(ERROR_NOTELF); 34 | } 35 | else if (elf->e_class != cls) { 36 | seterr(ERROR_CLASSMISMATCH); 37 | } 38 | else if (elf->e_ehdr || _elf_cook(elf)) { 39 | return elf->e_ehdr; 40 | } 41 | return NULL; 42 | } 43 | 44 | Elf32_Ehdr* 45 | elf32_getehdr(Elf *elf) { 46 | return (Elf32_Ehdr*)_elf_getehdr(elf, ELFCLASS32); 47 | } 48 | 49 | #if __LIBELF64 50 | 51 | Elf64_Ehdr* 52 | elf64_getehdr(Elf *elf) { 53 | return (Elf64_Ehdr*)_elf_getehdr(elf, ELFCLASS64); 54 | } 55 | 56 | #endif /* __LIBELF64 */ 57 | -------------------------------------------------------------------------------- /libelf/lib/32.getphdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | 32.getphdr.c - implementation of the elf{32,64}_getphdr(3) functions. 3 | Copyright (C) 1995 - 2000 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: 32.getphdr.c,v 1.11 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | char* 27 | _elf_getphdr(Elf *elf, unsigned cls) { 28 | if (!elf) { 29 | return NULL; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | if (elf->e_kind != ELF_K_ELF) { 33 | seterr(ERROR_NOTELF); 34 | } 35 | else if (elf->e_class != cls) { 36 | seterr(ERROR_CLASSMISMATCH); 37 | } 38 | else if (elf->e_ehdr || _elf_cook(elf)) { 39 | return elf->e_phdr; 40 | } 41 | return NULL; 42 | } 43 | 44 | Elf32_Phdr* 45 | elf32_getphdr(Elf *elf) { 46 | return (Elf32_Phdr*)_elf_getphdr(elf, ELFCLASS32); 47 | } 48 | 49 | #if __LIBELF64 50 | 51 | Elf64_Phdr* 52 | elf64_getphdr(Elf *elf) { 53 | return (Elf64_Phdr*)_elf_getphdr(elf, ELFCLASS64); 54 | } 55 | 56 | #endif /* __LIBELF64 */ 57 | -------------------------------------------------------------------------------- /libelf/lib/32.getshdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | 32.getshdr.c - implementation of the elf{32,64}_getshdr(3) functions. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: 32.getshdr.c,v 1.10 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf32_Shdr* 27 | elf32_getshdr(Elf_Scn *scn) { 28 | if (!scn) { 29 | return NULL; 30 | } 31 | elf_assert(scn->s_magic == SCN_MAGIC); 32 | elf_assert(scn->s_elf); 33 | elf_assert(scn->s_elf->e_magic == ELF_MAGIC); 34 | if (scn->s_elf->e_class == ELFCLASS32) { 35 | return &scn->s_shdr32; 36 | } 37 | seterr(ERROR_CLASSMISMATCH); 38 | return NULL; 39 | } 40 | 41 | #if __LIBELF64 42 | 43 | Elf64_Shdr* 44 | elf64_getshdr(Elf_Scn *scn) { 45 | if (!scn) { 46 | return NULL; 47 | } 48 | elf_assert(scn->s_magic == SCN_MAGIC); 49 | elf_assert(scn->s_elf); 50 | elf_assert(scn->s_elf->e_magic == ELF_MAGIC); 51 | if (scn->s_elf->e_class == ELFCLASS64) { 52 | return &scn->s_shdr64; 53 | } 54 | seterr(ERROR_CLASSMISMATCH); 55 | return NULL; 56 | } 57 | 58 | #endif /* __LIBELF64 */ 59 | -------------------------------------------------------------------------------- /libelf/lib/32.newehdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 32.newehdr.c - implementation of the elf{32,64}_newehdr(3) functions. 3 | * Copyright (C) 1995 - 2006 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: 32.newehdr.c,v 1.16 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | static char* 27 | _elf_newehdr(Elf *elf, unsigned cls) { 28 | size_t size; 29 | 30 | if (!elf) { 31 | return NULL; 32 | } 33 | elf_assert(elf->e_magic == ELF_MAGIC); 34 | if (elf->e_readable) { 35 | return _elf_getehdr(elf, cls); 36 | } 37 | else if (!elf->e_ehdr) { 38 | size = _msize(cls, _elf_version, ELF_T_EHDR); 39 | elf_assert(size); 40 | if ((elf->e_ehdr = (char*)malloc(size))) { 41 | memset(elf->e_ehdr, 0, size); 42 | elf->e_ehdr_flags |= ELF_F_DIRTY; 43 | elf->e_kind = ELF_K_ELF; 44 | elf->e_class = cls; 45 | return elf->e_ehdr; 46 | } 47 | seterr(ERROR_MEM_EHDR); 48 | } 49 | else if (elf->e_class != cls) { 50 | seterr(ERROR_CLASSMISMATCH); 51 | } 52 | else { 53 | elf_assert(elf->e_kind == ELF_K_ELF); 54 | return elf->e_ehdr; 55 | } 56 | return NULL; 57 | } 58 | 59 | Elf32_Ehdr* 60 | elf32_newehdr(Elf *elf) { 61 | return (Elf32_Ehdr*)_elf_newehdr(elf, ELFCLASS32); 62 | } 63 | 64 | #if __LIBELF64 65 | 66 | Elf64_Ehdr* 67 | elf64_newehdr(Elf *elf) { 68 | return (Elf64_Ehdr*)_elf_newehdr(elf, ELFCLASS64); 69 | } 70 | 71 | unsigned long 72 | gelf_newehdr(Elf *elf, int cls) { 73 | if (!valid_class(cls) || !_msize(cls, _elf_version, ELF_T_EHDR)) { 74 | seterr(ERROR_UNKNOWN_CLASS); 75 | return 0; 76 | } 77 | return (unsigned long)_elf_newehdr(elf, cls); 78 | } 79 | 80 | #endif /* __LIBELF64 */ 81 | -------------------------------------------------------------------------------- /libelf/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libelf C) 2 | 3 | file(GLOB_RECURSE SOURCES "${PROJECT_SOURCE_DIR}/*.c") 4 | add_library(libelf SHARED ${SOURCES}) 5 | set_target_properties(libelf PROPERTIES OUTPUT_NAME "retdec-libelf") 6 | target_include_directories(libelf SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}) 7 | if(MSVC) 8 | set_target_properties(libelf PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) 9 | endif() 10 | install(TARGETS libelf 11 | LIBRARY DESTINATION lib 12 | RUNTIME DESTINATION bin 13 | ) 14 | -------------------------------------------------------------------------------- /libelf/lib/assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | assert.c - assert function for libelf. 3 | Copyright (C) 1999 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: assert.c,v 1.5 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | #include 27 | 28 | void 29 | __elf_assert(const char *file, unsigned line, const char *cond) { 30 | fprintf(stderr, "%s:%u: libelf assertion failure: %s\n", 31 | file, line, cond); 32 | abort(); 33 | } 34 | -------------------------------------------------------------------------------- /libelf/lib/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem lib/build.bat - build script for W32 port 4 | rem Copyright (C) 2004 - 2006 Michael Riepe 5 | rem 6 | rem This library is free software; you can redistribute it and/or 7 | rem modify it under the terms of the GNU Library General Public 8 | rem License as published by the Free Software Foundation; either 9 | rem version 2 of the License, or (at your option) any later version. 10 | rem 11 | rem This library is distributed in the hope that it will be useful, 12 | rem but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | rem Library General Public License for more details. 15 | rem 16 | rem You should have received a copy of the GNU Library General Public 17 | rem License along with this library; if not, write to the Free Software 18 | rem Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | rem @(#) $Id: build.bat,v 1.1 2006/08/21 18:03:48 michael Exp $ 21 | 22 | rem *** BEGIN EDIT HERE *** 23 | rem Please uncomment the line that suits your system: 24 | rem call "C:\Program Files\Microsoft Visual Studio\VC98\bin\vcvars32.bat" 25 | rem call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" 26 | rem call "C:\Programme\Microsoft Visual Studio\VC98\bin\vcvars32.bat" 27 | rem call "C:\Programme\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" 28 | rem OR, if you have to set the path to the compiler directly: 29 | rem set PATH="C:\PATH\TO\COMPILER\BINARY;%PATH%" 30 | rem Of course, you'll have to enter the correct path above. 31 | rem You may also have to change CC (default: cl.exe) in Makefile.w32. 32 | rem *** END EDIT HERE *** 33 | 34 | copy config.h.w32 config.h 35 | copy sys_elf.h.w32 sys_elf.h 36 | nmake /nologo /f Makefile.w32 %1 37 | -------------------------------------------------------------------------------- /libelf/lib/cntl.c: -------------------------------------------------------------------------------- 1 | /* 2 | cntl.c - implementation of the elf_cntl(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: cntl.c,v 1.7 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | int 27 | elf_cntl(Elf *elf, Elf_Cmd cmd) { 28 | Elf_Scn *scn; 29 | Elf *child; 30 | 31 | if (!elf) { 32 | return -1; 33 | } 34 | elf_assert(elf->e_magic == ELF_MAGIC); 35 | if (cmd == ELF_C_FDREAD) { 36 | if (!elf->e_readable) { 37 | seterr(ERROR_WRONLY); 38 | return -1; 39 | } 40 | } 41 | else if (cmd != ELF_C_FDDONE) { 42 | seterr(ERROR_INVALID_CMD); 43 | return -1; 44 | } 45 | if (elf->e_disabled) { 46 | return 0; 47 | } 48 | if (elf->e_kind == ELF_K_AR) { 49 | for (child = elf->e_members; child; child = child->e_link) { 50 | elf_assert(elf == child->e_parent); 51 | if (elf_cntl(child, cmd)) { 52 | return -1; 53 | } 54 | } 55 | } 56 | else if (elf->e_kind == ELF_K_ELF && cmd == ELF_C_FDREAD) { 57 | if (!elf->e_ehdr && !_elf_cook(elf)) { 58 | return -1; 59 | } 60 | for (scn = elf->e_scn_1; scn; scn = scn->s_link) { 61 | if (scn->s_index == SHN_UNDEF || scn->s_type == SHT_NULL) { 62 | continue; 63 | } 64 | else if (!elf_getdata(scn, NULL)) { 65 | return -1; 66 | } 67 | } 68 | } 69 | elf->e_disabled = 1; 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /libelf/lib/data.c: -------------------------------------------------------------------------------- 1 | /* 2 | * data.c - libelf internal variables. 3 | * Copyright (C) 1995 - 1998, 2007 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: data.c,v 1.8 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | unsigned _elf_version = EV_NONE; 27 | int _elf_errno = 0; 28 | int _elf_fill = 0; 29 | 30 | #if ENABLE_SANITY_CHECKS 31 | #define SANITY_CHECKS -1 32 | #else 33 | #define SANITY_CHECKS 0 34 | #endif 35 | 36 | int _elf_sanity_checks = SANITY_CHECKS; 37 | -------------------------------------------------------------------------------- /libelf/lib/errmsg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * errmsg.c - implementation of the elf_errmsg(3) function. 3 | * Copyright (C) 1995 - 1999, 2004 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: errmsg.c,v 1.11 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | #if HAVE_DGETTEXT 27 | # undef HAVE_CATGETS 28 | # include 29 | #else /* HAVE_DGETTEXT */ 30 | # define dgettext(dom, str) str 31 | #endif /* HAVE_DGETTEXT */ 32 | 33 | #if HAVE_CATGETS 34 | # include 35 | static nl_catd _libelf_cat = (nl_catd)0; 36 | #endif /* HAVE_CATGETS */ 37 | 38 | #if HAVE_DGETTEXT || HAVE_CATGETS 39 | static const char domain[] = "libelf"; 40 | #endif /* HAVE_DGETTEXT || HAVE_CATGETS */ 41 | 42 | #if PIC 43 | static const char *_messages[] = { 44 | #else /* PIC */ 45 | static const char *const _messages[] = { 46 | #endif /* PIC */ 47 | #define __err__(a,b) b, 48 | #include /* include string tables from errors.h */ 49 | #undef __err__ 50 | }; 51 | 52 | const char* 53 | elf_errmsg(int err) { 54 | if (err == 0) { 55 | err = _elf_errno; 56 | if (err == 0) { 57 | return NULL; 58 | } 59 | } 60 | else if (err == -1) { 61 | err = _elf_errno; 62 | } 63 | 64 | if (err < 0 || err >= ERROR_NUM || _messages[err] == NULL) { 65 | err = ERROR_UNKNOWN; 66 | } 67 | 68 | #if HAVE_CATGETS 69 | if (_libelf_cat == (nl_catd)0) { 70 | _libelf_cat = catopen(domain, 0); 71 | } 72 | if (_libelf_cat != (nl_catd)-1) { 73 | return catgets(_libelf_cat, 1, err + 1, _messages[err]); 74 | } 75 | #endif /* HAVE_CATGETS */ 76 | return dgettext(domain, _messages[err]); 77 | } 78 | -------------------------------------------------------------------------------- /libelf/lib/errno.c: -------------------------------------------------------------------------------- 1 | /* 2 | errno.c - implementation of the elf_errno(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: errno.c,v 1.7 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | int 27 | elf_errno(void) { 28 | int tmp = _elf_errno; 29 | 30 | _elf_errno = 0; 31 | return tmp; 32 | } 33 | -------------------------------------------------------------------------------- /libelf/lib/fill.c: -------------------------------------------------------------------------------- 1 | /* 2 | fill.c - implementation of the elf_fill(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: fill.c,v 1.7 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | void 27 | elf_fill(int fill) { 28 | _elf_fill = fill; 29 | } 30 | -------------------------------------------------------------------------------- /libelf/lib/getarhdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | getarhdr.c - implementation of the elf_getarhdr(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: getarhdr.c,v 1.7 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf_Arhdr* 27 | elf_getarhdr(Elf *elf) { 28 | if (!elf) { 29 | return NULL; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | if (elf->e_arhdr) { 33 | return elf->e_arhdr; 34 | } 35 | seterr(ERROR_NOTARCHIVE); 36 | return NULL; 37 | } 38 | -------------------------------------------------------------------------------- /libelf/lib/getaroff.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getaroff.c - implementation of the elf_getaroff(3) function. 3 | * Copyright (C) 2009 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: getaroff.c,v 1.1 2009/11/01 13:04:19 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | off_t 27 | elf_getaroff(Elf *elf) { 28 | Elf *ref; 29 | 30 | if (!elf) { 31 | return (off_t)-1; 32 | } 33 | elf_assert(elf->e_magic == ELF_MAGIC); 34 | if (!(ref = elf->e_parent)) { 35 | return (off_t)-1; 36 | } 37 | elf_assert(ref->e_magic == ELF_MAGIC); 38 | elf_assert(elf->e_base >= ref->e_base + SARMAG + sizeof(struct ar_hdr)); 39 | return (off_t)(elf->e_base - ref->e_base - sizeof(struct ar_hdr)); 40 | } 41 | -------------------------------------------------------------------------------- /libelf/lib/getbase.c: -------------------------------------------------------------------------------- 1 | /* 2 | getbase.c - implementation of the elf_getbase(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: getbase.c,v 1.7 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | off_t 27 | elf_getbase(Elf *elf) { 28 | if (!elf) { 29 | return -1; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | return (off_t)elf->e_base; 33 | } 34 | -------------------------------------------------------------------------------- /libelf/lib/getident.c: -------------------------------------------------------------------------------- 1 | /* 2 | getident.c - implementation of the elf_getident(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: getident.c,v 1.7 2008/05/23 08:15:34 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | char* 27 | elf_getident(Elf *elf, size_t *ptr) { 28 | size_t tmp; 29 | 30 | if (!ptr) { 31 | ptr = &tmp; 32 | } 33 | if (!elf) { 34 | *ptr = 0; 35 | return NULL; 36 | } 37 | elf_assert(elf->e_magic == ELF_MAGIC); 38 | if (elf->e_kind != ELF_K_ELF) { 39 | *ptr = elf->e_idlen; 40 | return elf->e_data; 41 | } 42 | if (elf->e_ehdr || _elf_cook(elf)) { 43 | *ptr = elf->e_idlen; 44 | return elf->e_ehdr; 45 | } 46 | *ptr = 0; 47 | return NULL; 48 | } 49 | -------------------------------------------------------------------------------- /libelf/lib/getscn.c: -------------------------------------------------------------------------------- 1 | /* 2 | getscn.c - implementation of the elf_getscn(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: getscn.c,v 1.7 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf_Scn* 27 | elf_getscn(Elf *elf, size_t index) { 28 | Elf_Scn *scn; 29 | 30 | if (!elf) { 31 | return NULL; 32 | } 33 | elf_assert(elf->e_magic == ELF_MAGIC); 34 | if (elf->e_kind != ELF_K_ELF) { 35 | seterr(ERROR_NOTELF); 36 | } 37 | else if (elf->e_ehdr || _elf_cook(elf)) { 38 | for (scn = elf->e_scn_1; scn; scn = scn->s_link) { 39 | elf_assert(scn->s_magic == SCN_MAGIC); 40 | elf_assert(scn->s_elf == elf); 41 | if (scn->s_index == index) { 42 | return scn; 43 | } 44 | } 45 | seterr(ERROR_NOSUCHSCN); 46 | } 47 | return NULL; 48 | } 49 | -------------------------------------------------------------------------------- /libelf/lib/hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | hash.c - implementation of the elf_hash(3) function. 3 | Copyright (C) 1995 - 2002 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: hash.c,v 1.10 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | unsigned long 27 | elf_hash(const unsigned char *name) { 28 | unsigned long hash = 0; 29 | unsigned long tmp; 30 | 31 | while (*name) { 32 | hash = (hash << 4) + (unsigned char)*name++; 33 | if ((tmp = hash & 0xf0000000)) { 34 | hash ^= tmp | (tmp >> 24); 35 | } 36 | } 37 | return hash; 38 | } 39 | -------------------------------------------------------------------------------- /libelf/lib/kind.c: -------------------------------------------------------------------------------- 1 | /* 2 | kind.c - implementation of the elf_kind(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: kind.c,v 1.7 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf_Kind 27 | elf_kind(Elf *elf) { 28 | if (!elf) { 29 | return ELF_K_NONE; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | return elf->e_kind; 33 | } 34 | -------------------------------------------------------------------------------- /libelf/lib/libelf.def: -------------------------------------------------------------------------------- 1 | LIBRARY libelf 2 | VERSION 0.8 3 | EXPORTS 4 | elf_begin 5 | elf_cntl 6 | elf_delscn 7 | elf_end 8 | elf_errmsg 9 | elf_errno 10 | elf_fill 11 | elf_flagdata 12 | elf_flagehdr 13 | elf_flagelf 14 | elf_flagphdr 15 | elf_flagscn 16 | elf_flagshdr 17 | elf_getarhdr 18 | elf_getarsym 19 | elf_getbase 20 | elf_getdata 21 | elf_getident 22 | elf_getscn 23 | elf_hash 24 | elf_kind 25 | elf_memory 26 | elf_ndxscn 27 | elf_newdata 28 | elf_newscn 29 | elf_next 30 | elf_nextscn 31 | elf_rand 32 | elf_rawdata 33 | elf_rawfile 34 | elf_strptr 35 | elf_update 36 | elf_version 37 | elf32_checksum 38 | elf32_fsize 39 | elf32_getehdr 40 | elf32_getphdr 41 | elf32_getshdr 42 | elf32_newehdr 43 | elf32_newphdr 44 | elf32_xlatetof 45 | elf32_xlatetom 46 | elf64_checksum 47 | elf64_fsize 48 | elf64_getehdr 49 | elf64_getphdr 50 | elf64_getshdr 51 | elf64_newehdr 52 | elf64_newphdr 53 | elf64_xlatetof 54 | elf64_xlatetom 55 | elfx_movscn 56 | elfx_remscn 57 | gelf_checksum 58 | gelf_fsize 59 | gelf_getclass 60 | gelf_getdyn 61 | gelf_getehdr 62 | gelf_getphdr 63 | gelf_getrel 64 | gelf_getrela 65 | gelf_getshdr 66 | gelf_getsym 67 | gelf_msize 68 | gelf_newehdr 69 | gelf_newphdr 70 | gelf_update_dyn 71 | gelf_update_ehdr 72 | gelf_update_phdr 73 | gelf_update_rel 74 | gelf_update_rela 75 | gelf_update_shdr 76 | gelf_update_sym 77 | gelf_xlatetof 78 | gelf_xlatetom 79 | elf_getphnum 80 | elf_getshnum 81 | elf_getshstrndx 82 | elfx_update_shstrndx 83 | -------------------------------------------------------------------------------- /libelf/lib/memset.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memset.c - replacement for memset(3), using duff's device. 3 | * Copyright (C) 1995 - 2004 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #if HAVE_CONFIG_H 21 | # include 22 | #endif /* HAVE_CONFIG_H */ 23 | 24 | #ifndef lint 25 | static const char rcsid[] = "@(#) $Id: memset.c,v 1.11 2008/05/23 08:15:35 michael Exp $"; 26 | #endif /* lint */ 27 | 28 | #include /* for size_t */ 29 | #include 30 | 31 | void* 32 | _elf_memset(void *s, int c, size_t n) { 33 | char *t = (char*)s; 34 | 35 | if (n) { 36 | switch (n % 8u) { 37 | do { 38 | n -= 8; 39 | default: 40 | case 0: *t++ = (char)c; 41 | case 7: *t++ = (char)c; 42 | case 6: *t++ = (char)c; 43 | case 5: *t++ = (char)c; 44 | case 4: *t++ = (char)c; 45 | case 3: *t++ = (char)c; 46 | case 2: *t++ = (char)c; 47 | case 1: *t++ = (char)c; 48 | } 49 | while (n > 8); 50 | } 51 | } 52 | return s; 53 | } 54 | -------------------------------------------------------------------------------- /libelf/lib/ndxscn.c: -------------------------------------------------------------------------------- 1 | /* 2 | ndxscn.c - implementation of the elf_ndxscn(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: ndxscn.c,v 1.7 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | size_t 27 | elf_ndxscn(Elf_Scn *scn) { 28 | if (!scn) { 29 | return SHN_UNDEF; 30 | } 31 | elf_assert(scn->s_magic == SCN_MAGIC); 32 | return scn->s_index; 33 | } 34 | -------------------------------------------------------------------------------- /libelf/lib/newdata.c: -------------------------------------------------------------------------------- 1 | /* 2 | newdata.c - implementation of the elf_newdata(3) function. 3 | Copyright (C) 1995 - 2000 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: newdata.c,v 1.10 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf_Data* 27 | elf_newdata(Elf_Scn *scn) { 28 | Scn_Data *sd; 29 | 30 | if (!scn) { 31 | return NULL; 32 | } 33 | elf_assert(scn->s_magic == SCN_MAGIC); 34 | if (scn->s_index == SHN_UNDEF) { 35 | seterr(ERROR_NULLSCN); 36 | } 37 | else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) { 38 | seterr(ERROR_MEM_SCNDATA); 39 | } 40 | else { 41 | *sd = _elf_data_init; 42 | sd->sd_scn = scn; 43 | sd->sd_data_flags = ELF_F_DIRTY; 44 | sd->sd_freeme = 1; 45 | sd->sd_data.d_version = _elf_version; 46 | if (scn->s_data_n) { 47 | scn->s_data_n->sd_link = sd; 48 | } 49 | else { 50 | scn->s_data_1 = sd; 51 | } 52 | scn->s_data_n = sd; 53 | return &sd->sd_data; 54 | } 55 | return NULL; 56 | } 57 | -------------------------------------------------------------------------------- /libelf/lib/next.c: -------------------------------------------------------------------------------- 1 | /* 2 | next.c - implementation of the elf_next(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: next.c,v 1.7 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf_Cmd 27 | elf_next(Elf *elf) { 28 | if (!elf) { 29 | return ELF_C_NULL; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | if (!elf->e_parent) { 33 | return ELF_C_NULL; 34 | } 35 | elf_assert(elf->e_parent->e_magic == ELF_MAGIC); 36 | elf_assert(elf->e_parent->e_kind == ELF_K_AR); 37 | elf->e_parent->e_off = elf->e_next; 38 | if (elf->e_next == elf->e_parent->e_size) { 39 | return ELF_C_NULL; 40 | } 41 | return ELF_C_READ; 42 | } 43 | -------------------------------------------------------------------------------- /libelf/lib/nextscn.c: -------------------------------------------------------------------------------- 1 | /* 2 | nextscn.c - implementation of the elf_nextscn(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: nextscn.c,v 1.7 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | Elf_Scn* 27 | elf_nextscn(Elf *elf, Elf_Scn *scn) { 28 | if (!elf) { 29 | return NULL; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | if (scn) { 33 | elf_assert(scn->s_magic == SCN_MAGIC); 34 | if (scn->s_elf == elf) { 35 | return scn->s_link; 36 | } 37 | seterr(ERROR_ELFSCNMISMATCH); 38 | } 39 | else if (elf->e_kind != ELF_K_ELF) { 40 | seterr(ERROR_NOTELF); 41 | } 42 | else if (elf->e_ehdr || _elf_cook(elf)) { 43 | elf_assert(elf->e_ehdr); 44 | for (scn = elf->e_scn_1; scn; scn = scn->s_link) { 45 | elf_assert(scn->s_magic == SCN_MAGIC); 46 | elf_assert(scn->s_elf == elf); 47 | if (scn->s_index == 1) { 48 | return scn; 49 | } 50 | } 51 | seterr(ERROR_NOSUCHSCN); 52 | } 53 | return NULL; 54 | } 55 | -------------------------------------------------------------------------------- /libelf/lib/nlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nlist.h - public header file for nlist(3). 3 | * Copyright (C) 1995 - 2006 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | /* @(#) $Id: nlist.h,v 1.10 2008/05/23 08:15:35 michael Exp $ */ 21 | 22 | #ifndef _NLIST_H 23 | #define _NLIST_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif /* __cplusplus */ 28 | 29 | struct nlist { 30 | char* n_name; 31 | long n_value; 32 | short n_scnum; 33 | unsigned short n_type; 34 | char n_sclass; 35 | char n_numaux; 36 | }; 37 | 38 | #if (__STDC__ + 0) || defined(__cplusplus) || defined(_WIN32) 39 | extern int nlist(const char *__filename, struct nlist *__nl); 40 | #else /* __STDC__ || defined(__cplusplus) */ 41 | extern int nlist(); 42 | #endif /* __STDC__ || defined(__cplusplus) */ 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif /* __cplusplus */ 47 | 48 | #endif /* _NLIST_H */ 49 | -------------------------------------------------------------------------------- /libelf/lib/rand.c: -------------------------------------------------------------------------------- 1 | /* 2 | rand.c - implementation of the elf_rand(3) function. 3 | Copyright (C) 1995 - 1998 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: rand.c,v 1.7 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | size_t 27 | elf_rand(Elf *elf, size_t offset) { 28 | if (!elf) { 29 | return 0; 30 | } 31 | elf_assert(elf->e_magic == ELF_MAGIC); 32 | if (elf->e_kind != ELF_K_AR) { 33 | seterr(ERROR_NOTARCHIVE); 34 | } 35 | else if (offset <= 0 || offset > elf->e_size) { 36 | seterr(ERROR_BADOFF); 37 | } 38 | else { 39 | elf->e_off = offset; 40 | return offset; 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /libelf/lib/rawfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rawfile.c - implementation of the elf_rawfile(3) function. 3 | * Copyright (C) 1995 - 2009 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: rawfile.c,v 1.8 2009/05/22 17:07:46 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | char* 27 | elf_rawfile(Elf *elf, size_t *ptr) { 28 | size_t tmp; 29 | 30 | if (!ptr) { 31 | ptr = &tmp; 32 | } 33 | *ptr = 0; 34 | if (!elf) { 35 | return NULL; 36 | } 37 | elf_assert(elf->e_magic == ELF_MAGIC); 38 | if (!elf->e_readable) { 39 | return NULL; 40 | } 41 | else if (elf->e_size) { 42 | if (!elf->e_rawdata) { 43 | elf_assert(elf->e_data); 44 | if (!elf->e_cooked) { 45 | elf->e_rawdata = elf->e_data; 46 | } 47 | else if (!(elf->e_rawdata = _elf_read(elf, NULL, 0, elf->e_size))) { 48 | return NULL; 49 | } 50 | } 51 | *ptr = elf->e_size; 52 | } 53 | return elf->e_rawdata; 54 | } 55 | -------------------------------------------------------------------------------- /libelf/lib/verdef_32_tof.c: -------------------------------------------------------------------------------- 1 | /* 2 | verdef_32_tof.c - copy 32-bit versioning information. 3 | Copyright (C) 2001 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if __LIBELF_SYMBOL_VERSIONS 25 | 26 | #ifndef lint 27 | static const char rcsid[] = "@(#) $Id: verdef_32_tof.c,v 1.5 2008/05/23 08:15:35 michael Exp $"; 28 | #endif /* lint */ 29 | 30 | typedef Elf32_Verdaux verdaux_mtype; 31 | typedef Elf32_Verdef verdef_mtype; 32 | typedef Elf32_Vernaux vernaux_mtype; 33 | typedef Elf32_Verneed verneed_mtype; 34 | typedef Elf32_Word align_mtype; 35 | 36 | typedef __ext_Elf32_Verdaux verdaux_ftype; 37 | typedef __ext_Elf32_Verdef verdef_ftype; 38 | typedef __ext_Elf32_Vernaux vernaux_ftype; 39 | typedef __ext_Elf32_Verneed verneed_ftype; 40 | typedef __ext_Elf32_Word align_ftype; 41 | 42 | #define class_suffix 32 43 | 44 | #undef TOFILE 45 | #define TOFILE 1 46 | 47 | /* 48 | * Include shared code 49 | */ 50 | #include "verdef.h" 51 | #include "verneed.h" 52 | 53 | #endif /* __LIBELF_SYMBOL_VERSIONS */ 54 | -------------------------------------------------------------------------------- /libelf/lib/verdef_32_tom.c: -------------------------------------------------------------------------------- 1 | /* 2 | verdef_32_tom.c - copy 32-bit versioning information. 3 | Copyright (C) 2001 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if __LIBELF_SYMBOL_VERSIONS 25 | 26 | #ifndef lint 27 | static const char rcsid[] = "@(#) $Id: verdef_32_tom.c,v 1.5 2008/05/23 08:15:35 michael Exp $"; 28 | #endif /* lint */ 29 | 30 | typedef Elf32_Verdaux verdaux_mtype; 31 | typedef Elf32_Verdef verdef_mtype; 32 | typedef Elf32_Vernaux vernaux_mtype; 33 | typedef Elf32_Verneed verneed_mtype; 34 | typedef Elf32_Word align_mtype; 35 | 36 | typedef __ext_Elf32_Verdaux verdaux_ftype; 37 | typedef __ext_Elf32_Verdef verdef_ftype; 38 | typedef __ext_Elf32_Vernaux vernaux_ftype; 39 | typedef __ext_Elf32_Verneed verneed_ftype; 40 | typedef __ext_Elf32_Word align_ftype; 41 | 42 | #define class_suffix 32 43 | 44 | #undef TOFILE 45 | #define TOFILE 0 46 | 47 | /* 48 | * Include shared code 49 | */ 50 | #include "verdef.h" 51 | #include "verneed.h" 52 | 53 | #endif /* __LIBELF_SYMBOL_VERSIONS */ 54 | -------------------------------------------------------------------------------- /libelf/lib/verdef_64_tof.c: -------------------------------------------------------------------------------- 1 | /* 2 | verdef_64_tof.c - copy 64-bit versioning information. 3 | Copyright (C) 2001 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if __LIBELF64 && __LIBELF_SYMBOL_VERSIONS 25 | 26 | #ifndef lint 27 | static const char rcsid[] = "@(#) $Id: verdef_64_tof.c,v 1.5 2008/05/23 08:15:35 michael Exp $"; 28 | #endif /* lint */ 29 | 30 | typedef Elf64_Verdaux verdaux_mtype; 31 | typedef Elf64_Verdef verdef_mtype; 32 | typedef Elf64_Vernaux vernaux_mtype; 33 | typedef Elf64_Verneed verneed_mtype; 34 | typedef Elf64_Word align_mtype; 35 | 36 | typedef __ext_Elf64_Verdaux verdaux_ftype; 37 | typedef __ext_Elf64_Verdef verdef_ftype; 38 | typedef __ext_Elf64_Vernaux vernaux_ftype; 39 | typedef __ext_Elf64_Verneed verneed_ftype; 40 | typedef __ext_Elf64_Word align_ftype; 41 | 42 | #define class_suffix 64 43 | 44 | #undef TOFILE 45 | #define TOFILE 1 46 | 47 | /* 48 | * Include shared code 49 | */ 50 | #include "verdef.h" 51 | #include "verneed.h" 52 | 53 | #endif /* __LIBELF64 && __LIBELF_SYMBOL_VERSIONS */ 54 | -------------------------------------------------------------------------------- /libelf/lib/verdef_64_tom.c: -------------------------------------------------------------------------------- 1 | /* 2 | verdef_64_tom.c - copy 64-bit versioning information. 3 | Copyright (C) 2001 Michael Riepe 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if __LIBELF64 && __LIBELF_SYMBOL_VERSIONS 25 | 26 | #ifndef lint 27 | static const char rcsid[] = "@(#) $Id: verdef_64_tom.c,v 1.5 2008/05/23 08:15:35 michael Exp $"; 28 | #endif /* lint */ 29 | 30 | typedef Elf64_Verdaux verdaux_mtype; 31 | typedef Elf64_Verdef verdef_mtype; 32 | typedef Elf64_Vernaux vernaux_mtype; 33 | typedef Elf64_Verneed verneed_mtype; 34 | typedef Elf64_Word align_mtype; 35 | 36 | typedef __ext_Elf64_Verdaux verdaux_ftype; 37 | typedef __ext_Elf64_Verdef verdef_ftype; 38 | typedef __ext_Elf64_Vernaux vernaux_ftype; 39 | typedef __ext_Elf64_Verneed verneed_ftype; 40 | typedef __ext_Elf64_Word align_ftype; 41 | 42 | #define class_suffix 64 43 | 44 | #undef TOFILE 45 | #define TOFILE 0 46 | 47 | /* 48 | * Include shared code 49 | */ 50 | #include "verdef.h" 51 | #include "verneed.h" 52 | 53 | #endif /* __LIBELF64 && __LIBELF_SYMBOL_VERSIONS */ 54 | -------------------------------------------------------------------------------- /libelf/lib/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * version.c - implementation of the elf_version(3) function. 3 | * Copyright (C) 1995 - 1998, 2007 Michael Riepe 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef lint 23 | static const char rcsid[] = "@(#) $Id: version.c,v 1.8 2008/05/23 08:15:35 michael Exp $"; 24 | #endif /* lint */ 25 | 26 | unsigned 27 | elf_version(unsigned ver) { 28 | const char *s; 29 | unsigned tmp; 30 | 31 | if ((s = getenv("LIBELF_SANITY_CHECKS"))) { 32 | _elf_sanity_checks = (int)strtol(s, (char**)NULL, 0); 33 | } 34 | if (ver == EV_NONE) { 35 | return EV_CURRENT; 36 | } 37 | if (!valid_version(ver)) { 38 | seterr(ERROR_UNKNOWN_VERSION); 39 | return EV_NONE; 40 | } 41 | tmp = _elf_version == EV_NONE ? EV_CURRENT : _elf_version; 42 | _elf_version = ver; 43 | return tmp; 44 | } 45 | -------------------------------------------------------------------------------- /libelf/libelf.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @PACKAGE@ 7 | Description: ELF object file access library 8 | Version: @VERSION@ 9 | Requires: 10 | Conflicts: 11 | Libs: -L${libdir} -lelf 12 | Cflags: -I${includedir}/libelf -I${includedir} 13 | -------------------------------------------------------------------------------- /libelf/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Make directory hierarchy. 3 | # Written by Noah Friedman 4 | # Public domain. 5 | 6 | defaultIFS=' 7 | ' 8 | IFS="${IFS-${defaultIFS}}" 9 | 10 | errstatus=0 11 | 12 | for file in ${1+"$@"} ; do 13 | oIFS="${IFS}" 14 | # Some sh's can't handle IFS=/ for some reason. 15 | IFS='%' 16 | set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'` 17 | IFS="${oIFS}" 18 | 19 | pathcomp='' 20 | 21 | for d in ${1+"$@"} ; do 22 | pathcomp="${pathcomp}${d}" 23 | 24 | if test ! -d "${pathcomp}"; then 25 | echo "mkdir $pathcomp" 1>&2 26 | mkdir "${pathcomp}" || errstatus=$? 27 | fi 28 | 29 | pathcomp="${pathcomp}/" 30 | done 31 | done 32 | 33 | exit $errstatus 34 | 35 | # eof 36 | -------------------------------------------------------------------------------- /libelf/po/de.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libelf/po/de.gmo -------------------------------------------------------------------------------- /libelf/po/de.msg: -------------------------------------------------------------------------------- 1 | $set 1 Automatically created from de.gmo by gmo2msg 2 | -------------------------------------------------------------------------------- /libelf/po/de.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avast/libdwarf/7d4f63f44d44386744628ee1bca84afc43a56583/libelf/po/de.po -------------------------------------------------------------------------------- /libelf/po/stamp-po: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /libelf/stamp-h.in: -------------------------------------------------------------------------------- 1 | timestamp 2 | --------------------------------------------------------------------------------