Bump to v0.9.2

This commit is contained in:
Jeremy 2024-04-27 14:10:16 -05:00
parent 5c0cb251f9
commit 02ecf2cbca
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
41 changed files with 831 additions and 385 deletions

24
CMakeLists.txt vendored
View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5)
project(libdwarf VERSION 0.9.1 LANGUAGES C CXX)
# libdwarf
# libdwarf
option(BUILD_NON_SHARED "build archive library libdwarf[p].a" TRUE)
option(BUILD_SHARED "build shared library libdwarf[p].so and use it" FALSE)
@ -35,7 +35,7 @@ include_directories( ${PROJECT_BINARY_DIR} )
macro(msvc_posix target)
if(MSVC AND ("${MSVC_VERSION}" LESS 1900))
# under VS 2015
target_compile_definitions(${target} PUBLIC
target_compile_definitions(${target} PUBLIC
snprintf=_snprintf)
endif()
endmacro()
@ -60,7 +60,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if (LIBDWARF_CRT STREQUAL "MT")
message(STATUS "Using MT runtime by compile flag replacement")
# taken from the CMake FAQ
foreach(flag_v
foreach(flag_v
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
@ -120,7 +120,7 @@ include(CheckCSourceRuns)
include(CheckSymbolExists)
### Version also appears in configure.ac
set(VERSION 0.9.2)
set(PACKAGE_VERSION "\"${VERSION}\"")
set(PACKAGE_VERSION "\"${VERSION}\"")
set(PACKAGE_NAME "libdwarf" )
set(PACKAGE_STRING "\"${PACKAGE_NAME} ${VERSION}\"")
string(REGEX REPLACE "[\"]" "" tarname1 "${PACKAGE_STRING}" )
@ -132,12 +132,12 @@ if (${isBigEndian})
set ( WORDS_BIGENDIAN 1 )
endif()
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
check_include_file( "stdint.h" HAVE_STDINT_H )
check_include_file( "unistd.h" HAVE_UNISTD_H )
check_include_file( "stdafx.h" HAVE_STDAFX_H )
check_include_file( "fcntl.h" HAVE_FCNTL_H )
check_include_file( "fcntl.h" HAVE_FCNTL_H )
### cmake provides no way to guarantee uint32_t present.
### configure does guarantee that.
@ -164,7 +164,7 @@ else()
set(uintptr_t "unsigned long long int" )
message(STATUS "Setting #define uintptr_t " ${uintptr_t})
endif()
if (uintptr_t)
if (uintptr_t)
message(STATUS "uintptr_t value considered YES ")
else()
message(STATUS "uintptr_t value considered NO ")
@ -176,7 +176,7 @@ else()
set(intptr_t "long long int" )
message(STATUS "Setting #define intptr_t " ${intptr_t})
endif()
if (intptr_t)
if (intptr_t)
message(STATUS "intptr_t value considered YES ")
else()
message(STATUS "intptr_t value considered NO ")
@ -200,10 +200,10 @@ if (ENABLE_DECOMPRESSION)
TARGET ZSTD::ZSTD
)
)
find_package(ZSTD)
find_package(zstd)
else()
# Presumably in this case, the target has been found externally but set this flag just in case
set(ZSTD_FOUND TRUE)
set(zstd_FOUND TRUE)
endif()
# Unfortunately aliasing ZSTD::ZSTD to zstd::libzstd_shared/static can lead to problems for end-users, a variable
# is used
@ -218,7 +218,7 @@ if (ENABLE_DECOMPRESSION)
else()
set(ZSTD_LIB ZSTD::ZSTD)
endif()
if (ZLIB_FOUND AND ZSTD_FOUND )
if (ZLIB_FOUND AND zstd_FOUND )
set(HAVE_ZLIB TRUE)
set(HAVE_ZLIB_H TRUE)
set(HAVE_ZSTD TRUE)

10
cmake/FindZSTD.cmake vendored
View File

@ -6,7 +6,7 @@
# libdwarf/LIBDWARFCOPYRIGHT
# or https://github.com/root-project/root/blob/master/LICENSE
# For the list of contributors in the project that
# created this cmake file see
# created this cmake file see
# https://github.com/root-project/root/blob/master/README/CREDITS
#.rst:
@ -28,13 +28,13 @@
#
# ::
#
# ZSTD_FOUND - True if ZSTD is found.
# zstd_FOUND - True if ZSTD is found.
# ZSTD_INCLUDE_DIRS - Where to find zstd.h
#
# Finds the Zstandard library. This module defines:
# - ZSTD_INCLUDE_DIR, directory containing headers
# - ZSTD_LIBRARIES, the Zstandard library path
# - ZSTD_FOUND, whether Zstandard has been found
# - zstd_FOUND, whether Zstandard has been found
# Find header files
find_path(ZSTD_INCLUDE_DIR zstd.h)
@ -53,9 +53,9 @@ endif ()
find_library(ZSTD_LIBRARIES NAMES zstd)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZSTD REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIR ZSTD_VERSION VERSION_VAR ZSTD_VERSION)
find_package_handle_standard_args(zstd REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIR ZSTD_VERSION VERSION_VAR ZSTD_VERSION)
if (ZSTD_FOUND)
if (zstd_FOUND)
if (NOT TARGET ZSTD::ZSTD)
add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
set_target_properties(ZSTD::ZSTD PROPERTIES IMPORTED_LOCATION "${ZSTD_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIR}")

View File

@ -29,7 +29,7 @@
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to the uintptr_t to the type of an unsigned integer
/* Define to the uintptr_t to the type of an unsigned integer
type wide enough to hold a pointer
if the system does not define it. */
#cmakedefine uintptr_t ${uintptr_t}
@ -87,7 +87,7 @@
#cmakedefine PACKAGE_VERSION ${PACKAGE_VERSION}
/* Version number of package */
#cmakedefine VERSION ${VERSION}
#cmakedefine VERSION ${VERSION}
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */

View File

@ -7,7 +7,8 @@ git clone https://github.com/davea42/libdwarf-code.git
cd libdwarf-code
#git checkout "6216e185863f41d6f19ab850caabfff7326020d7" # v0.8.0
#git checkout "8b0bd09d8c77d45a68cb1bb00a54186a92b683d9" # v0.9.0
git checkout "8cdcc531f310d1c5ae61da469d8056bdd36b77e7" # v0.9.1 + cmake fixes
#git checkout "8cdcc531f310d1c5ae61da469d8056bdd36b77e7" # v0.9.1 + cmake fixes
git checkout "5e43a5ab73cb00c8a46660b361366a8c9c3c93c9" # v0.9.2
cd ..
echo "Copying files"
mkdir -p src/lib

View File

@ -1,30 +1,30 @@
set_source_group(SOURCES "Source Files" dwarf_abbrev.c
dwarf_alloc.c dwarf_crc.c dwarf_crc32.c dwarf_arange.c
set_source_group(SOURCES "Source Files" dwarf_abbrev.c
dwarf_alloc.c dwarf_crc.c dwarf_crc32.c dwarf_arange.c
dwarf_debug_sup.c
dwarf_debugaddr.c
dwarf_debuglink.c dwarf_die_deliv.c
dwarf_debugaddr.c
dwarf_debuglink.c dwarf_die_deliv.c
dwarf_debugnames.c dwarf_dsc.c
dwarf_elf_load_headers.c
dwarf_elfread.c
dwarf_elf_rel_detector.c
dwarf_error.c
dwarf_elf_load_headers.c
dwarf_elfread.c
dwarf_elf_rel_detector.c
dwarf_error.c
dwarf_fill_in_attr_form.c
dwarf_find_sigref.c dwarf_fission_to_cu.c
dwarf_form.c dwarf_form_class_names.c
dwarf_frame.c dwarf_frame2.c
dwarf_gdbindex.c dwarf_global.c
dwarf_gnu_index.c dwarf_groups.c
dwarf_harmless.c dwarf_generic_init.c dwarf_init_finish.c
dwarf_leb.c
dwarf_line.c dwarf_loc.c
dwarf_gdbindex.c dwarf_global.c
dwarf_gnu_index.c dwarf_groups.c
dwarf_harmless.c dwarf_generic_init.c dwarf_init_finish.c
dwarf_leb.c
dwarf_line.c dwarf_loc.c
dwarf_loclists.c
dwarf_locationop_read.c
dwarf_machoread.c dwarf_macro.c dwarf_macro5.c
dwarf_memcpy_swap.c
dwarf_names.c
dwarf_object_read_common.c dwarf_object_detector.c
dwarf_peread.c
dwarf_query.c dwarf_ranges.c
dwarf_peread.c
dwarf_query.c dwarf_ranges.c
dwarf_rnglists.c
dwarf_safe_arithmetic.c
dwarf_safe_strcpy.c
@ -33,43 +33,43 @@ dwarf_seekr.c
dwarf_setup_sections.c
dwarf_string.h dwarf_string.c
dwarf_stringsection.c
dwarf_tied.c
dwarf_tied.c
dwarf_str_offsets.c
dwarf_tsearchhash.c dwarf_util.c
dwarf_tsearchhash.c dwarf_util.c
dwarf_xu_index.c
dwarf_print_lines.c )
set_source_group(HEADERS "Header Files" dwarf.h dwarf_abbrev.h
dwarf_alloc.h dwarf_arange.h dwarf_base_types.h
dwarf_alloc.h dwarf_arange.h dwarf_base_types.h
dwarf_debugaddr.h
dwarf_debuglink.h dwarf_die_deliv.h
dwarf_debugnames.h dwarf_dsc.h
dwarf_elf_access.h dwarf_elf_defines.h dwarf_elfread.h
dwarf_elf_rel_detector.h
dwarf_elfstructs.h
dwarf_error.h dwarf_frame.h
dwarf_gdbindex.h dwarf_global.h dwarf_harmless.h
dwarf_gnu_index.h
dwarf_line.h dwarf_loc.h
dwarf_machoread.h dwarf_macro.h dwarf_macro5.h
dwarf_object_detector.h dwarf_opaque.h
dwarf_debuglink.h dwarf_die_deliv.h
dwarf_debugnames.h dwarf_dsc.h
dwarf_elf_access.h dwarf_elf_defines.h dwarf_elfread.h
dwarf_elf_rel_detector.h
dwarf_elfstructs.h
dwarf_error.h dwarf_frame.h
dwarf_gdbindex.h dwarf_global.h dwarf_harmless.h
dwarf_gnu_index.h
dwarf_line.h dwarf_loc.h
dwarf_machoread.h dwarf_macro.h dwarf_macro5.h
dwarf_object_detector.h dwarf_opaque.h
dwarf_pe_descr.h dwarf_peread.h
dwarf_reading.h
dwarf_rnglists.h
dwarf_safe_arithmetic.h
dwarf_safe_strcpy.h
dwarf_tied_decls.h
dwarf_tsearch.h
dwarf_tied_decls.h
dwarf_tsearch.h
dwarf_setup_sections.h
dwarf_str_offsets.h
dwarf_universal.h
dwarf_util.h
dwarf_universal.h
dwarf_util.h
dwarf_xu_index.h libdwarf_private.h
dwarf_macho_loader.h
dwarf_memcpy_swap.h)
set_source_group(CONFIGURATION_FILES "Configuration Files"
${PROJECT_SOURCE_DIR}/cmake/config.h.cmake
set_source_group(CONFIGURATION_FILES "Configuration Files"
${PROJECT_SOURCE_DIR}/cmake/config.h.cmake
${PROJECT_BINARY_DIR}/config.h)
# The -DPIC is so we find the right DW_API value in libdwarf.h
@ -105,8 +105,8 @@ target_include_directories(dwarf PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(ZLIB_FOUND AND ZSTD_FOUND)
target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ${ZSTD_LIB} )
if(ZLIB_FOUND AND zstd_FOUND)
target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ${ZSTD_LIB} )
endif()
set_target_properties(dwarf PROPERTIES PUBLIC_HEADER "libdwarf.h;dwarf.h")
@ -136,4 +136,4 @@ install(EXPORT libdwarfTargets
NAMESPACE libdwarf::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libdwarf")
install(FILES "${PROJECT_BINARY_DIR}/src/lib/libdwarf/libdwarf.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES "${PROJECT_SOURCE_DIR}/cmake/FindZSTD.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libdwarf")
install(FILES "${PROJECT_SOURCE_DIR}/cmake/Findzstd.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libdwarf")

View File

@ -4,24 +4,24 @@ The files:
dwarf.h
and most of the .h and .c files in this implementation of
libdwarf and libdwarfp are copyrighted according to the file
LIBDWARFCOPYRIGHT (which mentions the LGPL version 2.1).
LIBDWARFCOPYRIGHT (which mentions the LGPL version 2.1).
Each file mentions the LGPL.
The full text of the LGPL 2.1 is provided in LGPL.txt
Another copyright used here in some files is the
Another copyright used here in some files is the
two-clause BSD license, (FreeBSD license).
The libdwarf documentation:
libdwarf.mm
is based on material submitted to the UI PLSIG as proposed
interfaces for dwarf, but completely rewritten.
Copyright ownership is therefore SGI (but see the
interfaces for dwarf, but completely rewritten.
Copyright ownership is therefore SGI (but see the
document for details) and it seems clear that the
intent was there was to be free
copying with no fees.
libdwarfp.mm
is documentation of a set of interfaces
is documentation of a set of interfaces
(not part of the UI PLSIG proposals)
and the document was written from scratch at SGI.
Copyright ownership is therefore SGI (but see the

View File

@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an

View File

@ -7,7 +7,7 @@ if(LIBDWARF_BUILT_WITH_ZLIB_AND_ZSTD)
find_dependency(ZLIB)
set(CMAKE_MODULE_PATH_OLD "${CMAKE_MODULE_PATH}")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}")
find_dependency(ZSTD)
find_dependency(zstd)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_OLD}")
unset(CMAKE_MODULE_PATH_OLD)
endif()

View File

@ -13,7 +13,7 @@ DWversion
2,3,4,5 meaning the DWARF standards
x meaning gcc's experimental two level line table.
2345x 1. unit_length (4 or 12 bytes)
2345x 1. unit_length (4 or 12 bytes)
2345x 2. version (2 bytes, for x is 0xF006)
5 2.1 address_size
5 2.2 segment_selector_size

View File

@ -157,7 +157,7 @@ extern "C" {
/* TI = Texas Instruments, for DWARF in COFF */
/* https://www.ti.com/lit/an/spraab5/spraab5.pdf?ts=1705994928599 */
#define DW_TAG_lo_user 0x4080 /* TI */
#define DW_TAG_TI_far_type 0x4080 /* TI */
#define DW_TAG_MIPS_loop 0x4081
@ -167,7 +167,6 @@ extern "C" {
#define DW_TAG_TI_restrict_type 0x4084 /* TI */
#define DW_TAG_TI_onchip_type 0x4085 /* TI */
/* HP extensions: ftp://ftp.hp.com/pub/lang/tools/\
WDB/wdb-4.0.tar.gz */
#define DW_TAG_HP_array_descriptor 0x4090 /* HP */
@ -1191,13 +1190,13 @@ most-likely-useful name. */
#define DW_LANG_Assembly 0x0031 /* DWARF6 */
#define DW_LANG_C_sharp 0x0032 /* DWARF6 */
#define DW_LANG_Mojo 0x0033 /* DWARF6 */
#define DW_LANG_GLSL 0x0034 /* DWARF6 */
#define DW_LANG_GLSL_ES 0x0035 /* DWARF6 */
#define DW_LANG_HLSL 0x0036 /* DWARF6 */
#define DW_LANG_OpenCL_CPP 0x0037 /* DWARF6 */
#define DW_LANG_CPP_for_OpenCL 0x0038 /* DWARF6 */
#define DW_LANG_SYCL 0x0039 /* DWARF6 */
#define DW_LANG_Ruby 0x0040 /* DWARF6 */
#define DW_LANG_GLSL 0x0034 /* DWARF6 */
#define DW_LANG_GLSL_ES 0x0035 /* DWARF6 */
#define DW_LANG_HLSL 0x0036 /* DWARF6 */
#define DW_LANG_OpenCL_CPP 0x0037 /* DWARF6 */
#define DW_LANG_CPP_for_OpenCL 0x0038 /* DWARF6 */
#define DW_LANG_SYCL 0x0039 /* DWARF6 */
#define DW_LANG_Ruby 0x0040 /* DWARF6 */
#define DW_LANG_lo_user 0x8000
#define DW_LANG_Mips_Assembler 0x8001 /* MIPS */
@ -1426,7 +1425,8 @@ most-likely-useful name. */
See http://sourceforge.net/p/elftoolchain/tickets/397/ */
#define DW_CFA_METAWARE_info 0x34
#define DW_CFA_high_user 0x3f
#define DW_CFA_hi_user 0x3f
#define DW_CFA_high_user 0x3f /* Misspelled. Do not use. */
/* GNU exception header encoding. See the Generic
Elf Specification of the Linux Standard Base (LSB).

View File

@ -143,6 +143,7 @@ _dwarf_error_destructor(void *m)
#if DEBUG_ALLOC
printf("libdwarfdetector DEALLOC Now destruct error "
"string %s\n",dwarfstring_string(erm));
fflush(stdout);
#endif /* DEBUG_ALLOC */
dwarfstring_destructor(erm);
free(erm);
@ -182,6 +183,8 @@ struct reserve_data_s {
#define STATIC_ALLOWED 10 /* arbitrary, must be > 2, see below*/
static unsigned static_used = 0;
/* entries in this list point to allocations of
type DW_DLA_ERROR. */
static Dwarf_Error staticerrlist[STATIC_ALLOWED];
/* Clean this out if found */
@ -215,7 +218,7 @@ dw_empty_errlist_item(Dwarf_Error e_in)
}
}
/* If the userr calls dwarf_dealloc on an error
/* If the user calls dwarf_dealloc on an error
out of a dwarf_init*() call, this will find
it in the static err list. Here dbg is NULL
so not mentioned. */
@ -226,11 +229,21 @@ _dwarf_add_to_static_err_list(Dwarf_Error error)
if (!error) {
return;
}
#ifdef DEBUG_ALLOC
printf("\nlibdwarfdetector add to static err list "
" 0x%lx\n",(unsigned long)(uintptr_t)error);
fflush(stdout);
#endif /* DEBUG_ALLOC */
for ( ; i <static_used; ++i) {
Dwarf_Error e = staticerrlist[i];
if (e) {
continue;
}
#ifdef DEBUG_ALLOC
printf("libdwarfdetector add to static err list at %u\n",
i);
fflush(stdout);
#endif /* DEBUG_ALLOC */
staticerrlist[i] = error;
return;
}
@ -239,6 +252,38 @@ _dwarf_add_to_static_err_list(Dwarf_Error error)
++static_used;
}
}
/* See libdwarf vulnerability DW202402-002
for the motivation.
*/
static void
_dwarf_remove_from_staticerrlist(Dwarf_Ptr *space)
{
unsigned i = 0;
if (!space) {
return;
}
#ifdef DEBUG_ALLOC
printf("\nlibdwarfdetector remove from static err list "
" 0x%lx\n",(unsigned long)(uintptr_t)space);
fflush(stdout);
#endif /* DEBUG_ALLOC */
for ( ; i <static_used; ++i) {
Dwarf_Error e = staticerrlist[i];
if (!e) {
continue;
}
if ((void *)e == space) {
#ifdef DEBUG_ALLOC
printf("libdwarfdetector rm from static err list at %u\n",
i);
fflush(stdout);
#endif /* DEBUG_ALLOC */
staticerrlist[i] = 0;
return;
}
}
}
/* This will free everything in the staticerrlist,
but that is ok */
void
@ -671,7 +716,7 @@ _dwarf_get_alloc(Dwarf_Debug dbg,
}
}
#if DEBUG_ALLOC
printf("libdwarfdetector ALLOC ret 0x%lx type 0x%x "
printf("\nlibdwarfdetector ALLOC ret 0x%lx type 0x%x "
"size %lu line %d %s\n",
(unsigned long)ret_mem,(unsigned)alloc_type,
(unsigned long)size,__LINE__,__FILE__);
@ -804,6 +849,9 @@ dwarf_dealloc(Dwarf_Debug dbg,
unsigned int type = 0;
char * malloc_addr = 0;
struct reserve_data_s * r = 0;
#if 0
Dwarf_Bool check_errmsg_list = FALSE;
#endif
if (!space) {
#ifdef DEBUG_ALLOC
@ -921,11 +969,15 @@ dwarf_dealloc(Dwarf_Debug dbg,
if (ep->er_static_alloc == DE_MALLOC) {
/* This is special, we had no arena
but have a full special area as normal. */
#if 0
check_errmsg_list = TRUE;
#endif
#ifdef DEBUG_ALLOC
printf("DEALLOC does free, DE_MALLOC line %d %s\n",
__LINE__,__FILE__);
fflush(stdout);
#endif /* DEBUG_ALLOC*/
_dwarf_remove_from_staticerrlist(space);
}
/* Was normal alloc, use normal dealloc. */
/* DW_DLA_ERROR has a specialdestructor */

View File

@ -132,7 +132,7 @@ dwarf_basic_crc32 (const unsigned char *buf,
unsigned int crc)
{
const unsigned char *end = 0;
if (!buf) {
return 0;
}

View File

@ -49,7 +49,7 @@
The crc is calculated based on reading
the entire current open
Dwarf_Debug dbg object file and all bytes in
the file are read to create the crc.
the file are read to create the crc.
In Windows, where unsigned int is 16 bits, this
produces different output than on 32bit ints.

View File

@ -608,9 +608,9 @@ finish_cu_context_via_cudie_inner(
cudie, &bad_pc_form,
error);
if (resdwob == DW_DLV_NO_ENTRY) {
/* The CU die has no children or has
some other issue like DW_FORM_ref_addr
on a low or high pc attribute. (Metrowerks) */
/* The CU die has no children or has
some other issue like DW_FORM_ref_addr
on a low or high pc attribute. (Metrowerks) */
if (local_cudie_return) {
*local_cudie_return = cudie;
} else {
@ -1155,17 +1155,15 @@ _dwarf_set_children_flag(Dwarf_CU_Context cucon,
}
}
static int
_dwarf_prod_contains(const char *ck, const char *prod)
{
const char *cp = prod;
size_t len = strlen(ck);
for( ; *cp ; ++cp) {
for (; *cp ; ++cp) {
if ( ck[0] != *cp) {
continue;
continue;
}
if (strncmp(ck,cp,len)) {
continue;
@ -1187,9 +1185,9 @@ set_producer_type(Dwarf_Die die,
res = dwarf_die_text(die,DW_AT_producer,&producer,&error);
if (res == DW_DLV_ERROR) {
dwarf_dealloc_error(cu_context->cc_dbg,error);
error = 0;
return;
dwarf_dealloc_error(cu_context->cc_dbg,error);
error = 0;
return;
}
if (res == DW_DLV_NO_ENTRY) {
return;
@ -1275,9 +1273,9 @@ find_cu_die_base_fields(Dwarf_Debug dbg,
break;
}
switch(attrnum) {
case DW_AT_producer:
set_producer_type(cudie,cu_context);
break;
case DW_AT_producer:
set_producer_type(cudie,cu_context);
break;
case DW_AT_dwo_id:
case DW_AT_GNU_dwo_id: {
Dwarf_Sig8 signature;

View File

@ -211,7 +211,7 @@ generic_ehdr_from_32(dwarf_elf_object_access_internals_t *ep,
} else {
ehdr->ge_shnum_in_shnum = TRUE;
if (!ehdr->ge_shnum) {
return DW_DLV_NO_ENTRY;
return DW_DLV_NO_ENTRY;
}
if (ehdr->ge_shnum < 3) {
*errcode = DW_DLE_TOO_FEW_SECTIONS;
@ -280,7 +280,7 @@ generic_ehdr_from_64(dwarf_elf_object_access_internals_t* ep,
} else {
ehdr->ge_shnum_in_shnum = TRUE;
if (!ehdr->ge_shnum) {
return DW_DLV_NO_ENTRY;
return DW_DLV_NO_ENTRY;
}
if (ehdr->ge_shnum < 3) {
*errcode = DW_DLE_TOO_FEW_SECTIONS;
@ -1993,7 +1993,8 @@ read_gs_section_group(
}
grouparray[0] = 1;
/* A .group section will have 0 to G sections
listed */
listed. Ignore the initial 'version' value
of 1 in [0] */
dp = dp + DWARF_32BIT_SIZE;
for ( i = 1; i < count; ++i,dp += DWARF_32BIT_SIZE) {
Dwarf_Unsigned gseca = 0;
@ -2002,29 +2003,31 @@ read_gs_section_group(
memcpy(dblock,dp,DWARF_32BIT_SIZE);
ASNAR(memcpy,gseca,dblock);
/* Loading gseca and gsecb with different endianness.
Only one of them can be of any use. */
ASNAR(_dwarf_memcpy_swap_bytes,gsecb,dblock);
if (!gseca) {
/* zero! Oops. No point in looking at gsecb */
free(data);
free(grouparray);
*errcode = DW_DLE_ELF_SECTION_GROUP_ERROR;
return DW_DLV_ERROR;
}
grouparray[i] = gseca;
if (gseca >= ep->f_loc_shdr.g_count) {
/* Might be confused endianness by
the compiler generating the SHT_GROUP.
This is pretty horrible. */
if (gsecb >= ep->f_loc_shdr.g_count) {
*errcode = DW_DLE_ELF_SECTION_GROUP_ERROR;
free(data);
free(grouparray);
return DW_DLV_ERROR;
}
/* Ok. Yes, ugly. */
/* Looks as though gsecb is the correct
interpretation. Yes, ugly. */
gseca = gsecb;
grouparray[i] = gseca;
}
grouparray[i] = gseca;
targpsh = ep->f_shdr + gseca;
if (_dwarf_ignorethissection(targpsh->gh_namestring)){
continue;

View File

@ -140,7 +140,8 @@ _dwarf_error_string(Dwarf_Debug dbg, Dwarf_Error * error,
errptr = &_dwarf_failsafe_error;
errptr->er_static_alloc = DE_STATIC;
#ifdef DEBUG
printf("libdwarf no dbg, fullystatic, "
printf("libdwarf no dbg to dwarf_error_string,"
" fullystatic, "
"using DE_STATIC alloc, addr"
" 0x%lx line %d %s\n",
(unsigned long)errptr,
@ -150,7 +151,7 @@ _dwarf_error_string(Dwarf_Debug dbg, Dwarf_Error * error,
errptr->er_static_alloc = DE_MALLOC;
#ifdef DEBUG
printf("libdwarf no dbg,leaks, "
printf("libdwarf no dbg, add to static_err_list "
"static DE_MALLOC alloc, addr"
" 0x%lx line %d %s\n",
(unsigned long)errptr,

View File

@ -48,6 +48,27 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "dwarf_util.h"
#include "dwarf_string.h"
static void
build_alloc_ab_error(Dwarf_Debug dbg,
Dwarf_Unsigned count,
const char *fieldname,
Dwarf_Error *error)
{
dwarfstring m;
dwarfstring_constructor(&m);
dwarfstring_append_printf_s(&m,
"DW_DLE_ALLOC_FAIL :"
" Attempt to malloc space for %s ",
(char *)fieldname);
dwarfstring_append_printf_u(&m,
" with %u entries failed.",
count);
_dwarf_error_string(dbg,error,DW_DLE_ALLOC_FAIL,
dwarfstring_string(&m));
dwarfstring_destructor(&m);
}
/*
This is a pre-scan of the abbrev/form list.
We will not handle DW_FORM_indirect here as that
@ -67,44 +88,29 @@ _dwarf_fill_in_attr_form_abtable(Dwarf_CU_Context context,
abbrev_list->abl_attr = (Dwarf_Half*)
calloc(abbrev_list->abl_abbrev_count,
SIZEOFT16);
if (!abbrev_list->abl_attr) {
build_alloc_ab_error(dbg,abbrev_list->abl_abbrev_count,
"abbrev_list->abl_attr",error);
return DW_DLV_ERROR;
}
abbrev_list->abl_form = (Dwarf_Half *)
calloc(abbrev_list->abl_abbrev_count,
SIZEOFT16);
if (!abbrev_list->abl_form) {
build_alloc_ab_error(dbg,abbrev_list->abl_abbrev_count,
"abbrev_list->abl_form",error);
return DW_DLV_ERROR;
}
if (abbrev_list->abl_implicit_const_count > 0) {
abbrev_list->abl_implicit_const = (Dwarf_Signed *)
calloc(abbrev_list->abl_abbrev_count,
sizeof(Dwarf_Signed));
if (!abbrev_list->abl_implicit_const) {
dwarfstring m;
dwarfstring_constructor(&m);
dwarfstring_append_printf_u(&m,
"DW_DLE_ALLOC_FAIL :"
" Attempt to malloc space for "
"abbrev_list->abl_implicit_const "
"with %u entries failed.",
abbrev_list->abl_abbrev_count);
_dwarf_error_string(dbg,error,DW_DLE_ALLOC_FAIL,
dwarfstring_string(&m));
dwarfstring_destructor(&m);
build_alloc_ab_error(dbg,abbrev_list->abl_abbrev_count,
"abbrev_list->abl_implicit_const",error);
return DW_DLV_ERROR;
}
}
if (!abbrev_list->abl_attr || !abbrev_list->abl_form ) {
dwarfstring m;
dwarfstring_constructor(&m);
dwarfstring_append_printf_u(&m,
"DW_DLE_ALLOC_FAIL :"
" Attempt to malloc space for "
"abbrev_list->abl_attr or abl_form "
"with %u entries failed.",
abbrev_list->abl_abbrev_count);
_dwarf_error_string(dbg,error,DW_DLE_ALLOC_FAIL,
dwarfstring_string(&m));
dwarfstring_destructor(&m);
return DW_DLV_ERROR;
}
for (i = 0; i < abbrev_list->abl_abbrev_count; ++i) {
Dwarf_Unsigned attr = 0;
@ -141,18 +147,13 @@ _dwarf_fill_in_attr_form_abtable(Dwarf_CU_Context context,
return res;
}
if (attr_form > 0xffff) {
dwarfstring m;
dwarfstring_constructor(&m);
dwarfstring_append(&m,
_dwarf_error_string(dbg, error,
DW_DLE_ATTR_FORM_SIZE_BAD,
"DW_DLE_ATTR_FORM_SIZE_BAD :"
" reading attr_form");
dwarfstring_append(&m,"an abbrev list entry "
"the ULEB form number is too large. "
" reading attr_form of"
" an abbrev list entry: "
"the ULEB form number is too large "
"to be valid. Corrupt Dwarf.");
_dwarf_error_string(dbg,error,DW_DLE_ATTR_FORM_SIZE_BAD,
dwarfstring_string(&m));
dwarfstring_destructor(&m);
return DW_DLV_ERROR;
}
if (!_dwarf_valid_form_we_know(attr_form,attr)) {

View File

@ -444,7 +444,7 @@ show_not_ref_error(Dwarf_Debug dbg,
/*DW_DLE_NOT_REF_FORM */
dwarfstring_constructor(&m);
dwarf_get_FORM_name(form,&fname);
dwarf_get_AT_name(attr,&aname);
dwarfstring_append(&m,"DW_DLE_NOT_REF_FORM: ");
@ -783,6 +783,13 @@ _dwarf_internal_global_formref_b(Dwarf_Attribute attr,
switch (attr->ar_attribute_form) {
case DW_FORM_ref1:
if (attr->ar_debug_ptr >= section_end) {
_dwarf_error_string(dbg, error,
DW_DLE_ATTR_FORM_OFFSET_BAD,
"DW_DLE_ATTR_FORM_OFFSET_BAD: "
"DW_FORM_ref1 outside of the section.");
return DW_DLV_ERROR;
}
offset = *(Dwarf_Small *) attr->ar_debug_ptr;
goto fixoffset;
@ -834,7 +841,7 @@ _dwarf_internal_global_formref_b(Dwarf_Attribute attr,
That was first clearly documented in DWARF3.
In DWARF4 these two forms are no longer references. */
case DW_FORM_data4:
if (context_version >= DW_CU_VERSION4) {
if (context_version >= DW_CU_VERSION4) {
show_not_ref_error(dbg,error,attr->ar_attribute_form,
attr->ar_attribute);
return DW_DLV_ERROR;
@ -1311,7 +1318,7 @@ dwarf_formaddr(Dwarf_Attribute attr,
}
if (attrform == DW_FORM_addr ||
(cu_context->cc_producer == CC_PROD_METROWERKS &&
attrform == DW_FORM_ref_addr)
attrform == DW_FORM_ref_addr)
/* Allowance of
DW_FORM_ref_addr was a mistake. The value returned in that
case is NOT an address it is a global debug_info
@ -1643,14 +1650,23 @@ _dwarf_formblock_internal(Dwarf_Debug dbg,
section_start =
_dwarf_calculate_info_section_start_ptr(cu_context,
&section_length);
switch (attr->ar_attribute_form) {
case DW_FORM_block1:
length = *(Dwarf_Small *) attr->ar_debug_ptr;
data = attr->ar_debug_ptr + sizeof(Dwarf_Small);
case DW_FORM_block1: {
Dwarf_Small *start = attr->ar_debug_ptr;
Dwarf_Small *incremented = start + 1;
if ( incremented < start ||
incremented >= section_end) {
/* Error if +1 overflows or if points out of section. */
generate_form_error(dbg,error,attr->ar_attribute_form,
DW_DLE_ATTR_FORM_BAD,
"DW_DLE_ATTR_FORM_BAD",
" DW_FORM_block1 offset invalid");
return DW_DLV_ERROR;
}
length = *start;
data = incremented;
break;
}
case DW_FORM_block2:
READ_UNALIGNED_CK(dbg, length, Dwarf_Unsigned,
attr->ar_debug_ptr, DWARF_HALF_SIZE,
@ -1679,7 +1695,7 @@ _dwarf_formblock_internal(Dwarf_Debug dbg,
generate_form_error(dbg,error,attr->ar_attribute_form,
DW_DLE_ATTR_FORM_BAD,
"DW_DLE_ATTR_FORM_BAD",
"dwarf_formblock");
"dwarf_formblock() finds unknown form");
return DW_DLV_ERROR;
}
/* We have the data. Check for errors. */

View File

@ -1812,7 +1812,8 @@ _dwarf_exec_frame_instr(Dwarf_Bool make_instr,
struct Dwarf_Reg_Rule_s *t2reg = table->fr_reg;
struct Dwarf_Reg_Rule_s *t3reg = localregtab;
unsigned minregcount = (unsigned)MIN(table->fr_reg_count,reg_count);
unsigned minregcount = (unsigned)MIN(table->fr_reg_count,
reg_count);
unsigned curreg = 0;
table->fr_loc = current_loc;
@ -2334,7 +2335,7 @@ dwarf_get_cie_info_b(Dwarf_Cie cie,
if (data_alignment_factor != NULL)
*data_alignment_factor = cie->ci_data_alignment_factor;
if (return_address_register != NULL)
*return_address_register =
*return_address_register =
(Dwarf_Half)cie->ci_return_address_register;
if (initial_instructions != NULL)
*initial_instructions = cie->ci_cie_instr_start;
@ -3276,10 +3277,11 @@ dump_frame_rule(char *msg, struct Dwarf_Reg_Rule_s *reg_rule)
Returns the value that was present before we changed it here. */
Dwarf_Half
dwarf_set_frame_rule_initial_value(Dwarf_Debug dbg, Dwarf_Half value)
dwarf_set_frame_rule_initial_value(Dwarf_Debug dbg,
Dwarf_Half value)
{
Dwarf_Half orig =
(Dwarf_Half)dbg->de_frame_rule_initial_value;
Dwarf_Half orig =
(Dwarf_Half)dbg->de_frame_rule_initial_value;
dbg->de_frame_rule_initial_value = value;
return orig;
}
@ -3298,7 +3300,7 @@ dwarf_set_frame_rule_initial_value(Dwarf_Debug dbg, Dwarf_Half value)
Dwarf_Half
dwarf_set_frame_rule_table_size(Dwarf_Debug dbg, Dwarf_Half value)
{
Dwarf_Half orig =
Dwarf_Half orig =
(Dwarf_Half)dbg->de_frame_reg_rules_entry_count;
dbg->de_frame_reg_rules_entry_count = value;
@ -3334,7 +3336,7 @@ dwarf_set_frame_cfa_value(Dwarf_Debug dbg, Dwarf_Half value)
Dwarf_Half
dwarf_set_frame_same_value(Dwarf_Debug dbg, Dwarf_Half value)
{
Dwarf_Half orig =
Dwarf_Half orig =
(Dwarf_Half)dbg->de_frame_same_value_number;
dbg->de_frame_same_value_number = value;
return orig;
@ -3342,7 +3344,7 @@ dwarf_set_frame_same_value(Dwarf_Debug dbg, Dwarf_Half value)
Dwarf_Half
dwarf_set_frame_undefined_value(Dwarf_Debug dbg, Dwarf_Half value)
{
Dwarf_Half orig =
Dwarf_Half orig =
(Dwarf_Half)dbg->de_frame_same_value_number;
dbg->de_frame_undefined_value_number = value;
return orig;

View File

@ -195,10 +195,11 @@ dwarf_gdbindex_header(Dwarf_Debug dbg,
}
data = dbg->de_debug_gdbindex.dss_data;
if (!data) {
/* Should be impossible, dwarf_load_section() would
return DW_DLV_ERROR if dss_data could not be
set non-null */
_dwarf_error_string(dbg, error, DW_DLE_ERRONEOUS_GDB_INDEX_SECTION,
/* Should be impossible, dwarf_load_section() would
return DW_DLV_ERROR if dss_data could not be
set non-null */
_dwarf_error_string(dbg, error,
DW_DLE_ERRONEOUS_GDB_INDEX_SECTION,
"DW_DLE_ERRONEOUS_GDB_INDEX_SECTION: "
"We have non-zero (section) dss_size but "
"null dss_data pointer");

View File

@ -1726,7 +1726,7 @@ dwarf_get_section_info_by_index_a(Dwarf_Debug dbg,
Dwarf_Unsigned sectioncount = 0;
CHECK_DBG(dbg,error,"dwarf_get_section_info_by_index_a()");
sectioncount = dwarf_get_section_count(dbg);
sectioncount = dwarf_get_section_count(dbg);
if (section_addr) {
*section_addr = 0;
@ -1747,7 +1747,7 @@ dwarf_get_section_info_by_index_a(Dwarf_Debug dbg,
return DW_DLV_NO_ENTRY;
}
/* Check if we have a valid section index */
if ((Dwarf_Unsigned)section_index < sectioncount){
if ((Dwarf_Unsigned)section_index < sectioncount){
int res = 0;
int err = 0;
struct Dwarf_Obj_Access_Section_a_s doas;

View File

@ -70,8 +70,13 @@
generate an leb with correct but useless trailing
zero bytes (note the interaction with sign in the signed case).
The value of BYTESLEBMAX is arbitrary but allows catching
corrupt data before dark.
Before April 2021 BYTESLEBMAX was 10.
corrupt data in a short time.
Before April 2021 BYTESLEBMAX was 10 as it was assumed
there were no 'useless' 0x80 high-order bytes in an LEB.
(0x80 meaning the 7 bits 'value' is zero)
However in DWARF6 (and at least one compiler before
DWARF6) a few high order bytes are allowed as padding.
*/
#define BYTESLEBMAX 24
#define BITSPERBYTE 8
@ -83,15 +88,15 @@ _dwarf_skip_leb128(char * leb128,
Dwarf_Unsigned * leb128_length,
char * endptr)
{
unsigned byte = 0;
unsigned byte = 0;
/* The byte_length value will be a small non-negative integer. */
unsigned byte_length = 1;
unsigned byte_length = 1;
if (leb128 >=endptr) {
return DW_DLV_ERROR;
}
byte = *leb128;
byte = *(unsigned char *)leb128;
if ((byte & 0x80) == 0) {
*leb128_length = 1;
return DW_DLV_OK;
@ -100,7 +105,7 @@ _dwarf_skip_leb128(char * leb128,
if ((leb128+1) >=endptr) {
return DW_DLV_ERROR;
}
byte2 = *(leb128 + 1);
byte2 = *(unsigned char *)(leb128 + 1);
if ((byte2 & 0x80) == 0) {
*leb128_length = 2;
return DW_DLV_OK;
@ -117,7 +122,7 @@ _dwarf_skip_leb128(char * leb128,
/* Off end of available space. */
return DW_DLV_ERROR;
}
byte = *leb128;
byte = *(unsigned char *)leb128;
if (byte & 0x80) {
if (byte_length >= BYTESLEBMAX) {
/* Too long. Not sane length. */
@ -129,21 +134,22 @@ _dwarf_skip_leb128(char * leb128,
}
*leb128_length = byte_length;
return DW_DLV_OK;
}
/* Decode ULEB with checking. */
/* Decode ULEB with checking.
Casting leb128 to (unsigned char *) as
the signedness of char * is unpredictable in C */
int
dwarf_decode_leb128(char * leb128,
Dwarf_Unsigned * leb128_length,
Dwarf_Unsigned *outval,
char * endptr)
{
unsigned byte = 0;
unsigned long byte = 0;
Dwarf_Unsigned word_number = 0;
Dwarf_Unsigned number = 0;
size_t shift = 0;
unsigned long shift = 0; /* at least 32 bits, even Win32 */
/* The byte_length value will be a small non-negative integer. */
unsigned byte_length = 0;
unsigned int byte_length = 0;
if (leb128 >=endptr) {
return DW_DLV_ERROR;
@ -152,7 +158,7 @@ dwarf_decode_leb128(char * leb128,
unpacks into 32 bits to make this as fast as possible.
word_number is assumed big enough that the shift has a defined
result. */
byte = *leb128;
byte = *(unsigned char *)leb128;
if ((byte & 0x80) == 0) {
if (leb128_length) {
*leb128_length = 1;
@ -162,16 +168,16 @@ dwarf_decode_leb128(char * leb128,
}
return DW_DLV_OK;
} else {
unsigned byte2 = 0;
unsigned long byte2 = 0;
if ((leb128+1) >=endptr) {
return DW_DLV_ERROR;
}
byte2 = *(leb128 + 1);
byte2 = *(unsigned char *)(leb128 + 1);
if ((byte2 & 0x80) == 0) {
if (leb128_length) {
*leb128_length = 2;
}
word_number = byte & 0x7f;
word_number = byte & 0x7f;
word_number |= (byte2 & 0x7f) << 7;
if (outval) {
*outval = word_number;
@ -189,7 +195,7 @@ dwarf_decode_leb128(char * leb128,
shift = 0;
byte_length = 1;
for (;;) {
unsigned b = byte & 0x7f;
unsigned int b = byte & 0x7f;
if (shift >= (sizeof(number)*BITSPERBYTE)) {
/* Shift is large. Maybe corrupt value,
maybe some padding high-end byte zeroes
@ -220,7 +226,7 @@ dwarf_decode_leb128(char * leb128,
return DW_DLV_ERROR;
}
++byte_length;
byte = *leb128;
byte = *(unsigned char *)leb128;
continue;
}
/* Too big, corrupt data given the non-zero
@ -250,24 +256,27 @@ dwarf_decode_leb128(char * leb128,
if (leb128 >= endptr) {
return DW_DLV_ERROR;
}
byte = *leb128;
byte = *(unsigned char *)leb128;
}
return DW_DLV_ERROR;
}
/* Decode SLEB with checking */
/* Decode SLEB with checking
Casting leb128 to (unsigned char *) as
the signedness of char * is unpredictable
in C */
int
dwarf_decode_signed_leb128(char * leb128,
Dwarf_Unsigned * leb128_length,
Dwarf_Signed *outval,char * endptr)
{
Dwarf_Unsigned byte = 0;
unsigned int b = 0;
Dwarf_Signed number = 0;
size_t shift = 0;
int sign = FALSE;
Dwarf_Unsigned byte = 0;
unsigned int b = 0;
Dwarf_Signed number = 0;
unsigned long shift = 0;
int sign = FALSE;
/* The byte_length value will be a small non-negative integer. */
unsigned byte_length = 1;
unsigned int byte_length = 1;
/* byte_length being the number of bytes
of data absorbed so far in
@ -278,7 +287,7 @@ dwarf_decode_signed_leb128(char * leb128,
if (leb128 >= endptr) {
return DW_DLV_ERROR;
}
byte = *leb128;
byte = *(unsigned char *)leb128;
for (;;) {
b = byte & 0x7f;
if (shift >= (sizeof(number)*BITSPERBYTE)) {
@ -307,7 +316,7 @@ dwarf_decode_signed_leb128(char * leb128,
if (leb128 >= endptr) {
return DW_DLV_ERROR;
}
byte = *leb128;
byte = *(unsigned char *)leb128;
continue;
}
/* Too big, corrupt data given the non-zero
@ -325,7 +334,7 @@ dwarf_decode_signed_leb128(char * leb128,
if (leb128 >= endptr) {
return DW_DLV_ERROR;
}
byte = *leb128;
byte = *(unsigned char *)leb128;
byte_length++;
if (byte_length > BYTESLEBMAX) {
/* Erroneous input. */
@ -337,7 +346,7 @@ dwarf_decode_signed_leb128(char * leb128,
}
if (sign) {
/* The following avoids undefined behavior. */
unsigned shiftlim = sizeof(Dwarf_Signed) * BITSPERBYTE -1;
unsigned int shiftlim = sizeof(Dwarf_Signed) * BITSPERBYTE -1;
if (shift < shiftlim) {
Dwarf_Signed y = (Dwarf_Signed)
(((Dwarf_Unsigned)1) << shift);

View File

@ -652,7 +652,7 @@ dwarf_srcfiles(Dwarf_Die die,
if (res != DW_DLV_OK) {
return res;
}
for (ifp = baseindex; ifp < endindex;
for (ifp = baseindex; ifp < endindex;
++ifp,fe2 = fe->fi_next ) {
int sres = 0;
char *name_out = 0;

View File

@ -782,6 +782,15 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
format_values[j].up_first;
Dwarf_Unsigned lnform =
format_values[j].up_second;
if (line_ptr >= line_ptr_end) {
free(format_values);
format_values = 0;
_dwarf_error_string(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR,
" Running off end of line table"
" reading directory path");
return DW_DLV_ERROR;
}
switch (lntype) {
case DW_LNCT_path: {
char *inc_dir_ptr = 0;
@ -851,6 +860,14 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
_dwarf_error(dbg, err, DW_DLE_ALLOC_FAIL);
return DW_DLV_ERROR;
}
if (line_ptr >= line_ptr_end) {
free(filename_entry_pairs);
_dwarf_error_string(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR,
"DW_DLE_LINE_NUMBER_HEADER_ERROR: "
"reading filename format entries");
return DW_DLV_ERROR;
}
for (i = 0; i < filename_format_count; i++) {
dres=read_uword_de(&line_ptr,
&filename_entry_pairs[i].up_first,
@ -900,7 +917,9 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
malloc(sizeof(struct Dwarf_File_Entry_s));
if (curline == NULL) {
free(filename_entry_pairs);
_dwarf_error(dbg, err, DW_DLE_ALLOC_FAIL);
_dwarf_error_string(dbg, err, DW_DLE_ALLOC_FAIL,
"DW_DLE_ALLOC_FAIL: "
"Unable to malloc Dwarf_File_Entry_s");
return DW_DLV_ERROR;
}
memset(curline,0,sizeof(*curline));
@ -911,6 +930,16 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
filename_entry_pairs[j].up_first;
Dwarf_Unsigned lnform =
filename_entry_pairs[j].up_second;
if (line_ptr >= line_ptr_end) {
free(filename_entry_pairs);
_dwarf_error_string(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR,
"DW_DLE_LINE_NUMBER_HEADER_ERROR: "
"file name format count too large "
"to be correct. Corrupt DWARF/");
return DW_DLV_ERROR;
}
switch (lntype) {
/* The LLVM LNCT is documented in
https://releases.llvm.org/9.0.0/docs
@ -1064,8 +1093,11 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
}
if (line_ptr > line_ptr_end) {
free(filename_entry_pairs);
_dwarf_error(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR);
_dwarf_error_string(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR,
"DW_DLE_LINE_NUMBER_HEADER_ERROR: "
"Reading line table header filenames "
"runs off end of section. Corrupt Dwarf");
return DW_DLV_ERROR;
}
}
@ -1106,6 +1138,15 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
free(subprog_entry_types);
return DW_DLV_ERROR;
}
if (line_ptr >= line_ptr_end) {
free(subprog_entry_types);
_dwarf_error_string(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR,
"DW_DLE_LINE_NUMBER_HEADER_ERROR: "
"Line table forms odd, experimental libdwarf");
return DW_DLV_ERROR;
}
subprog_entry_forms = malloc(sizeof(Dwarf_Unsigned) *
subprog_format_count);
if (subprog_entry_forms == NULL) {
@ -1180,6 +1221,17 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
for (i = 0; i < subprogs_count; i++) {
struct Dwarf_Subprog_Entry_s *curline =
line_context->lc_subprogs + i;
if (line_ptr >= line_ptr_end) {
free(subprog_entry_types);
free(subprog_entry_forms);
_dwarf_error_string(dbg, err,
DW_DLE_LINE_NUMBER_HEADER_ERROR,
"DW_DLE_LINE_NUMBER_HEADER_ERROR:"
" Reading suprogram entry subprogs"
" in experimental line table"
" we run off the end of the table");
return DW_DLV_ERROR;
}
for (j = 0; j < subprog_format_count; j++) {
Dwarf_Unsigned lntype =
subprog_entry_types[j];
@ -2358,7 +2410,7 @@ read_line_table_program(Dwarf_Debug dbg,
#ifdef PRINTING_DETAILS
print_line_detail(dbg,
"DW_LNE_end_sequence extended",
(int)ext_opcode,
(int)ext_opcode,
(unsigned int)line_count+1,&regs,
is_single_table, is_actuals_table);
#endif /* PRINTING_DETAILS */

View File

@ -116,6 +116,7 @@ counted_loc_descr(Dwarf_Debug dbg,
return DW_DLV_OK;
}
/* See also read_single_rle_entry() for similar code */
static int
read_single_lle_entry(Dwarf_Debug dbg,
Dwarf_Small *data,
@ -141,9 +142,18 @@ read_single_lle_entry(Dwarf_Debug dbg,
Dwarf_Unsigned loc_ops_len = 0;
Dwarf_Small *lopsdata = 0;
Dwarf_Unsigned lopsoffset = 0;
Dwarf_Small *startdata = 0;
/* Some of these have a Counted Location Description
in them. */
if (data >= enddata) {
_dwarf_error_string(dbg,error,DW_DLE_LOCLISTS_ERROR,
"DW_DLE_LOCLISTS_ERROR: "
"An lle entry begins past the end of "
"its allowed space. Corrupt DWARF.");
return DW_DLV_ERROR;
}
startdata = data;
code = *data;
++data;
++count;
@ -278,8 +288,24 @@ read_single_lle_entry(Dwarf_Debug dbg,
break;
}
{
unsigned int v = (unsigned int)count;
if ((Dwarf_Unsigned)v != count) {
/* We want to avoid overflow in additions, and
the overall section size is a reasonable check
on count. The sequence of tests is to
preserve a testing baseline:
baselines/hongg2024-02-18-m.base
otherwise we would test against sectionsize first.*/
Dwarf_Unsigned sectionsize = dbg->de_debug_loclists.dss_size;
if (data > enddata || data < startdata ) {
/* Corrupt data being read. */
_dwarf_error_string(dbg,error,DW_DLE_LOCLISTS_ERROR,
"DW_DLE_LOCLISTS_ERROR: "
"The end of an lle entry is past the end "
"of its allowed space");
return DW_DLV_ERROR;
}
if (count > sectionsize) {
/* Corrupt data being read. */
_dwarf_error_string(dbg,error,DW_DLE_LOCLISTS_ERROR,
"DW_DLE_LOCLISTS_ERROR: "
"The number of bytes in a single "
@ -1000,15 +1026,15 @@ build_array_of_lle(Dwarf_Debug dbg,
Dwarf_Unsigned i = 0;
for ( ; !done ; ) {
unsigned entrylen = 0;
unsigned code = 0;
Dwarf_Unsigned val1 = 0;
Dwarf_Unsigned val2 = 0;
unsigned int entrylen = 0;
unsigned int code = 0;
Dwarf_Unsigned val1 = 0;
Dwarf_Unsigned val2 = 0;
Dwarf_Locdesc_c e = 0;
Dwarf_Unsigned opsblocksize = 0;
Dwarf_Unsigned opsoffset = 0;
Dwarf_Small *ops = 0;
Dwarf_Block_c eops;
Dwarf_Unsigned opsblocksize = 0;
Dwarf_Unsigned opsoffset = 0;
Dwarf_Small *ops = 0;
Dwarf_Block_c eops;
memset(&eops,0,sizeof(eops));
res = read_single_lle_entry(dbg,

View File

@ -472,7 +472,7 @@ like environment variable */
#define LC_VERSION_MIN_WATCHOS 0x30
/* build for Watch min OS version */
#define LC_NOTE 0x31
#define LC_NOTE 0x31
/* arbitrary data included within a Mach-O file */
#define LC_BUILD_VERSION 0x32
@ -490,7 +490,6 @@ like environment variable */
#define LC_ATOM_INFO 0x36
/* used with linkedit_data_command */
/*
* A variable length string in a load command
* is represented by an lc_str

View File

@ -57,7 +57,6 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <config.h>
#include <stdlib.h> /* calloc() free() malloc() */
#include <string.h> /* memcpy() memset() strcmp() strdup() */

View File

@ -643,7 +643,7 @@ dwarf_get_macro_defundef(Dwarf_Macro_Context macro_context,
&localstring, &lerr);
if (resup != DW_DLV_OK) {
if (resup == DW_DLV_ERROR) {
Dwarf_Unsigned myerrno =
Dwarf_Unsigned myerrno =
(unsigned int)dwarf_errno(lerr);
if (myerrno == DW_DLE_NO_TIED_FILE_AVAILABLE) {
*macro_string =

View File

@ -1,5 +1,5 @@
/* Generated routines, do not edit. */
/* Generated for source version 0.9.1 */
/* Generated for source version 0.9.2 */
/* BEGIN FILE */
@ -3452,9 +3452,11 @@ dwarf_get_CFA_name (unsigned int val,
case DW_CFA_METAWARE_info:
*s_out = "DW_CFA_METAWARE_info";
return DW_DLV_OK;
case DW_CFA_high_user:
*s_out = "DW_CFA_high_user";
case DW_CFA_hi_user:
*s_out = "DW_CFA_hi_user";
return DW_DLV_OK;
/* Skipping alternate spelling of value
0x3f. DW_CFA_high_user */
case DW_CFA_advance_loc:
*s_out = "DW_CFA_advance_loc";
return DW_DLV_OK;

View File

@ -45,8 +45,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Neither off_t nor ssize_t is in C90.
However, both are in Posix:
IEEE Std 1003.1-1990, aka
ISO/IEC 9954-1:1990.
This gets asked to read large sections sometimes.
ISO/IEC 9954-1:1990.
This gets asked to read large sections sometimes.
The Linux kernel allows at most 0x7ffff000
bytes in a read()*/
int
@ -81,8 +81,8 @@ _dwarf_object_read_random(int fd, char *buf, Dwarf_Unsigned loc,
}
res = _dwarf_readr(fd,buf,size,0);
if (res != DW_DLV_OK) {
*errc = DW_DLE_READ_ERROR;
return DW_DLV_ERROR;
*errc = DW_DLE_READ_ERROR;
return DW_DLV_ERROR;
}
return DW_DLV_OK;
}

View File

@ -188,7 +188,6 @@ struct Dwarf_CU_Context_s {
See cc_is_info flag. */
Dwarf_Unsigned cc_debug_offset;
/* === START DEBUG FISSION (Split Dwarf) data
cc_signature is in the TU header
of a type unit of a TU DIE (or for DW5 in the
@ -655,7 +654,7 @@ struct Dwarf_Debug_s {
Dwarf_Unsigned de_obj_flags;
/* number of bytes in a pointer of the target in various .debug_
sections. 4 in 32bit, 8 in MIPS 64, ia64.
sections. 4 in 32bit, 8 in MIPS 64, ia64.
This is taken from object file headers. */
Dwarf_Small de_pointer_size;

View File

@ -449,7 +449,7 @@ print_file_entry_details(Dwarf_Debug dbg,
sizeof(locallinebuf));
if (line_version == DW_LINE_VERSION5) {
Dwarf_Unsigned i = 0;
Dwarf_Unsigned dfcount =
Dwarf_Unsigned dfcount =
line_context->lc_file_name_format_count;
dwarfstring_append_printf_u(&m5,

View File

@ -436,6 +436,8 @@ dwarf_attrlist(Dwarf_Die die,
if (bres != DW_DLV_OK) {
return bres;
}
/* Here we are guaranteed abbrev_list->abl_attr
is non-null */
}
/* ASSERT list->abl_addr and list->abl_form
are non-null and if list->abl_implicit_const_count > 0
@ -531,7 +533,7 @@ dwarf_attrlist(Dwarf_Die die,
return DW_DLV_ERROR;
}
new_attr->ar_attribute = (Dwarf_Half)attr;
new_attr->ar_attribute_form_direct =
new_attr->ar_attribute_form_direct =
(Dwarf_Half)attr_form;
new_attr->ar_attribute_form = (Dwarf_Half)newattr_form;
/* Here the final address must be *inside* the
@ -614,6 +616,23 @@ dwarf_attrlist(Dwarf_Die die,
return DW_DLV_OK;
}
static void
build_alloc_qu_error(Dwarf_Debug dbg,
const char *fieldname,
Dwarf_Error *error)
{
dwarfstring m;
dwarfstring_constructor(&m);
dwarfstring_append_printf_s(&m,
"DW_DLE_ALLOC_FAIL :"
" Attempt to malloc space for %s failed",
(char *)fieldname);
_dwarf_error_string(dbg,error,DW_DLE_ALLOC_FAIL,
dwarfstring_string(&m));
dwarfstring_destructor(&m);
}
/*
This function takes a die, and an attr, and returns
a pointer to the start of the value of that attr in
@ -719,7 +738,16 @@ _dwarf_get_value_ptr(Dwarf_Die die,
return bres;
}
}
if (!abbrev_list->abl_form) {
build_alloc_qu_error(dbg,"abbrev_list->abl_form"
" in _dwarf_get_value_ptr()", error);
return DW_DLV_ERROR;
}
if (!abbrev_list->abl_attr) {
build_alloc_qu_error(dbg,"abbrev_list->abl_attr"
" in _dwarf_get_value_ptr()", error);
return DW_DLV_ERROR;
}
for (i = 0; i < abbrev_list->abl_abbrev_count; ++i) {
Dwarf_Unsigned curr_attr_form = 0;
Dwarf_Unsigned curr_attr = 0;
@ -896,6 +924,11 @@ dwarf_attr(Dwarf_Die die,
return bres;
}
}
if (!abbrev_list->abl_form) {
build_alloc_qu_error(dbg,"abbrev_list->abl_form"
" in dwarf_attr()", error);
return DW_DLV_ERROR;
}
res = _dwarf_get_value_ptr(die, attr, &attr_form,&info_ptr,
&implicit_const,error);
if (res == DW_DLV_ERROR) {
@ -1696,6 +1729,8 @@ dwarf_arrayorder(Dwarf_Die die,
/* Return DW_DLV_OK if ok
DW_DLV_ERROR if failure.
attr must be a valid attribute pointer.
If the die and the attr are not related the result is
meaningless. */
int
@ -1720,6 +1755,9 @@ dwarf_attr_offset(Dwarf_Die die, Dwarf_Attribute attr,
Dwarf_Unsigned
dwarf_die_abbrev_code(Dwarf_Die die)
{
if (!die) {
return 0;
}
return die->di_abbrev_code;
}
@ -1730,6 +1768,9 @@ dwarf_die_abbrev_code(Dwarf_Die die)
int
dwarf_die_abbrev_children_flag(Dwarf_Die die,Dwarf_Half *ab_has_child)
{
if (!die) {
return DW_DLV_ERROR;
}
if (die->di_abbrev_list) {
*ab_has_child = die->di_abbrev_list->abl_has_child;
return DW_DLV_OK;

View File

@ -116,7 +116,7 @@ free_rnglists_chain(Dwarf_Debug dbg, Dwarf_Chain head)
}
}
}
/* See also read_single_lle_entry() for similar code */
static int
read_single_rle_entry(Dwarf_Debug dbg,
Dwarf_Small *data,
@ -134,7 +134,16 @@ read_single_rle_entry(Dwarf_Debug dbg,
unsigned code = 0;
Dwarf_Unsigned val1 = 0;
Dwarf_Unsigned val2 = 0;
Dwarf_Small * startdata = 0;
if (data >= enddata) {
_dwarf_error_string(dbg,error,DW_DLE_RNGLISTS_ERROR,
"DW_DLE_RNGLISTS_ERROR: "
"An rle entry begins past the end of "
"its allowed space. Corrupt DWARF.");
return DW_DLV_ERROR;
}
startdata = data;
code = *data;
++data;
++count;
@ -202,6 +211,35 @@ read_single_rle_entry(Dwarf_Debug dbg,
}
break;
}
{
/* We want to avoid overflow in additions, and
the overall section size is a reasonable check
on count. The sequence of tests is to
preserve a testing baseline:
baselines/hongg2024-02-18-m.base
otherwise we would test against sectionsize first.*/
Dwarf_Unsigned sectionsize = dbg->de_debug_rnglists.dss_size;
if (data > enddata || data < startdata ) {
/* Corrupt data being read. */
_dwarf_error_string(dbg,error,DW_DLE_RNGLISTS_ERROR,
"DW_DLE_RNGLISTS_ERROR: "
"The end of an rle entry is past the end "
"of its allowed space");
return DW_DLV_ERROR;
}
if (count > sectionsize) {
/* Corrupt data being read. */
_dwarf_error_string(dbg,error,DW_DLE_RNGLISTS_ERROR,
"DW_DLE_RNGLISTS_ERROR: "
"The number of bytes in a single "
"rnglist entry is "
"too large to be reasonable");
return DW_DLV_ERROR;
}
}
*bytes_count_out = (unsigned int)count;
*entry_kind = code;
*entry_operand1 = val1;
@ -711,7 +749,7 @@ int dwarf_get_rnglist_head_basics(
*bytes_total_in_rle = head->rh_bytes_total;
*offset_size = (Dwarf_Half)head->rh_offset_size;
*address_size = (Dwarf_Half)head->rh_address_size;
*segment_selector_size =
*segment_selector_size =
(Dwarf_Half)head->rh_segment_selector_size;
rngcontext = head->rh_localcontext;
if (rngcontext) {

View File

@ -51,6 +51,9 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif /* HAVE_FCNTL_H */
#ifdef _WIN64
#ifdef lseek /* defined in msys2 in an io.h */
#undef lseek
#endif /* lseek */
#define lseek _lseeki64
#endif /* _WIN64 */
@ -78,7 +81,6 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define O_CLOEXEC 0
#endif /* O_CLOEXEC */
#if 0 /* debugging only */
static void
dump_bytes(char * msg,Dwarf_Small * start, long len)
@ -150,7 +152,7 @@ _dwarf_seekr(int fd,
if (sloc < 0) {
return DW_DLV_ERROR;
}
#ifdef _WIN64
#ifdef _WIN64
fsize = (Dwarf_Signed)lseek(fd,(__int64)loc,seektype);
#elif defined(_WIN32)
fsize = (Dwarf_Signed)lseek(fd,(off_t)loc,seektype);
@ -167,9 +169,9 @@ _dwarf_seekr(int fd,
}
void
_dwarf_closer( int fd)
_dwarf_closer( int fd)
{
#ifdef _WIN64
#ifdef _WIN64
_close(fd);
#elif defined(_WIN32)
_close(fd);
@ -183,7 +185,7 @@ _dwarf_openr( const char *name)
{
int fd = -1;
#ifdef _WIN64
#ifdef _WIN64
fd = _open(name, O_RDONLY | O_BINARY|O_CLOEXEC);
#elif defined(_WIN32)
fd = _open(name, O_RDONLY | O_BINARY|O_CLOEXEC);

View File

@ -57,6 +57,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static unsigned long minimumnewlen = 30;
/* Here we set s_data to a valid pointer to a null byte, though
the s_size and s_avail are set to zero. */
int
dwarfstring_constructor(struct dwarfstring_s *g)
{
@ -67,22 +69,30 @@ dwarfstring_constructor(struct dwarfstring_s *g)
return TRUE;
}
/* We only increase the s_data space.
Only calling dwarfstring_destructor
eliminates space. */
static int
dwarfstring_resize_to(struct dwarfstring_s *g,size_t newlen)
dwarfstring_add_to(struct dwarfstring_s *g,size_t newlen)
{
char *b = 0;
/* s_size - s_avail is the string without counting
the null following the string. So, is strlen() */
size_t lastpos = g->s_size - g->s_avail;
size_t malloclen = newlen+1;
/* ASSERT: malloclen > g->s_size at both call points */
/* ASSERT: newlen as well as malloclen are
greater than g->s_size at both call points */
if (malloclen < minimumnewlen) {
malloclen = minimumnewlen;
}
/* Not zeroing the new buffer block. */
b = malloc(malloclen);
if (!b) {
return FALSE;
}
if (lastpos > 0) {
/* Copying the non-null bytes in s_data. */
memcpy(b,g->s_data,lastpos);
}
if (g->s_malloc) {
@ -90,6 +100,13 @@ dwarfstring_resize_to(struct dwarfstring_s *g,size_t newlen)
g->s_data = 0;
}
g->s_data = b;
/* s_data[lastpos] is one past the end of anything
counted as string
in s_data at the point of call, and is guaranteed
to be safe as we increased the size of s_data, we did not
shrink. And, too, we add 1 to newlen, always,
so space for a terminating null byte is guaranteed
available. */
g->s_data[lastpos] = 0;
g->s_size = newlen;
g->s_avail = newlen - lastpos;
@ -119,7 +136,7 @@ dwarfstring_constructor_fixed(struct dwarfstring_s *g,
if (len == 0) {
return TRUE;
}
r = dwarfstring_resize_to(g,len);
r = dwarfstring_add_to(g,len);
if (!r) {
return FALSE;
}
@ -162,6 +179,8 @@ int
dwarfstring_append_length(struct dwarfstring_s *g,char *str,
size_t slen)
{
/* lastpos is the length of characters
without the null-terminator we call it strlen */
size_t lastpos = g->s_size - g->s_avail;
int r = 0;
@ -172,7 +191,7 @@ dwarfstring_append_length(struct dwarfstring_s *g,char *str,
size_t newlen = 0;
newlen = g->s_size + slen+2;
r = dwarfstring_resize_to(g,newlen);
r = dwarfstring_add_to(g,newlen);
if (!r) {
/* Unable to resize, dare not do anything. */
return FALSE;
@ -180,6 +199,8 @@ dwarfstring_append_length(struct dwarfstring_s *g,char *str,
}
memcpy(g->s_data + lastpos,str,slen);
g->s_avail -= slen;
/* Adding string terminating null byte.
Space is guaranteed available to do this.*/
g->s_data[g->s_size - g->s_avail] = 0;
return TRUE;
}

View File

@ -634,7 +634,7 @@ copy_abbrev_table_to_new_table(Dwarf_Hash_Table htin,
order of the entries, effectively, but
that does not seem significant. */
if (newhash > htout->tb_highest_used_entry) {
htout->tb_highest_used_entry =
htout->tb_highest_used_entry =
(unsigned long)newhash;
}
listent->abl_next = entry_out[newhash];
@ -813,7 +813,7 @@ printf("debugging: initial size %u\n",HT_DEFAULT_TABLE_SIZE);
hash_num = hashable_val HT_MOD_OP
(hash_table_base->tb_table_entry_count-1);
if (hash_num > hash_table_base->tb_highest_used_entry) {
hash_table_base->tb_highest_used_entry =
hash_table_base->tb_highest_used_entry =
(unsigned long)hash_num;
}
entry_base = hash_table_base->tb_entries;
@ -917,7 +917,7 @@ printf("debugging: initial size %u\n",HT_DEFAULT_TABLE_SIZE);
hash_num = new_hashable_val HT_MOD_OP
(hash_table_base->tb_table_entry_count-1);
if (hash_num > hash_table_base->tb_highest_used_entry) {
hash_table_base->tb_highest_used_entry =
hash_table_base->tb_highest_used_entry =
(unsigned long)hash_num;
}
@ -1401,7 +1401,7 @@ _dwarf_error_mv_s_to_t(Dwarf_Debug dbgs,Dwarf_Error *errs,
/* copy errs errno to errt by building
a new errt.
variable if there is one!
Move the error from dbgs to dbgt.
Move the error from dbgs to dbgt.
Error numbers are all < 1000.
*/
mydw_errno = (int)dwarf_errno(*errs);

View File

@ -780,7 +780,7 @@ _dwarf_search_fission_for_offset(Dwarf_Debug dbg,
{
Dwarf_Unsigned i = 0;
Dwarf_Unsigned m = 0;
Dwarf_Unsigned secnum_index = 0;
Dwarf_Unsigned secnum_index = 0;
Dwarf_Bool found_secnum = FALSE;
int res = 0;
@ -869,7 +869,7 @@ transform_xu_to_dfp(Dwarf_Xu_Index_Header xuhdr,
Dwarf_Unsigned i = 0;
Dwarf_Unsigned l = 0;
Dwarf_Unsigned n = 1;
Dwarf_Unsigned max_cols =
Dwarf_Unsigned max_cols =
xuhdr->gx_column_count_sections;/* L */
Dwarf_Unsigned secnums[DW_FISSION_SECT_COUNT];
int res = 0;

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
#define LIBDWARF_PRIVATE_H
#define DW_PR_XZEROS "08"
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
#define DW_PR_DUx "I64x"
#define DW_PR_DSx "I64x"
#define DW_PR_DUu "I64u"

View File

@ -72,14 +72,14 @@ if dev_decompression
include_directories: ['/opt/local/include'])
endif
endif
if not libzstd_deps.found()
if fs.is_dir('/opt/local/lib') and fs.is_file('/opt/local/include/zstd.h')
libzstd_deps = declare_dependency(link_args: ['-L/opt/local/lib','-lzstd' ],
include_directories: ['/opt/local/include'])
endif
endif
if zlib_deps.found()
message(['Have zlib'])
else
@ -88,7 +88,7 @@ if dev_decompression
include_directories: ['/usr/local/include'])
endif
endif
if libzstd_deps.found()
message(['Have libzstd'])
else
@ -98,10 +98,10 @@ if dev_decompression
include_directories: ['/usr/local/include'])
endif
endif
# Using set10 as false has the wrong effect, does not
# Using set10 as false has the wrong effect, does not
# match what compilers expect from #ifdef in C.
if zlib_deps.found()
if zlib_deps.found()
if libzstd_deps.found()
config_h.set10('HAVE_ZSTD_H',true)
config_h.set10('HAVE_ZSTD',true)
@ -142,6 +142,8 @@ libdwarf = declare_dependency(
dependencies : [zlib_deps, libzstd_deps]
)
meson.override_dependency('libdwarf', libdwarf)
install_headers(libdwarf_header_src,
install_dir : dir_pkginclude + '-' + v_maj
)