Skip to content

Commit 4145956

Browse files
Felipe Kellermannacmel
Felipe Kellermann
authored andcommitted
[DWARVES] Fixes a FIXME relating to a missing elf (libdw) symbol check.
Signed-off-by: Felipe Kellermann <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 030f187 commit 4145956

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

cmake/modules/FindDWARF.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# DWARF_LIBRARIES - List of libraries when using elf utils.
66
# DWARF_FOUND - True if fdo found.
77

8+
INCLUDE(CheckLibraryExists)
89

910
if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY)
1011
# Already in cache, be silent
@@ -42,6 +43,9 @@ find_library(EBL_LIBRARY
4243
if (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY)
4344
set(DWARF_FOUND TRUE)
4445
set(DWARF_LIBRARIES ${DWARF_LIBRARY} ${ELF_LIBRARY} ${EBL_LIBRARY})
46+
47+
set(CMAKE_REQUIRED_LIBRARIES ${DWARF_LIBRARIES})
48+
check_library_exists(elf dwfl_module_build_id "" HAVE_DWFL_MODULE_BUILD_ID)
4549
else (DWARF_INCLUDE_DIR AND LIBDW_INCLUDE_DIR AND DWARF_LIBRARY AND ELF_LIBRARY AND EBL_LIBRARY)
4650
set(DWARF_FOUND FALSE)
4751
set(DWARF_LIBRARIES)
@@ -77,3 +81,4 @@ endif (DWARF_FOUND)
7781

7882
mark_as_advanced(DWARF_INCLUDE_DIR LIBDW_INCLUDE_DIR DWARF_LIBRARY ELF_LIBRARY EBL_LIBRARY)
7983
include_directories(${DWARF_INCLUDE_DIR} ${LIBDW_INCLUDE_DIR})
84+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)

config.h.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
Copyright (C) 2007 Arnaldo Carvalho de Melo <[email protected]>
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+
9+
#cmakedefine HAVE_DWFL_MODULE_BUILD_ID

dwarves.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string.h>
2525
#include <unistd.h>
2626

27+
#include "config.h"
2728
#include "list.h"
2829
#include "dwarves.h"
2930
#include "dutil.h"
@@ -3482,11 +3483,8 @@ static int cus__load_module(Dwfl_Module *mod, void **userdata __unused,
34823483
size_t cuhl;
34833484
GElf_Addr vaddr;
34843485
const unsigned char *build_id = NULL;
3485-
/*
3486-
* FIXME: check how to do this properly using cmake to test for
3487-
* the existence of dwfl_module_build_id in the elfutils libraries.
3488-
*/
3489-
#if 1
3486+
3487+
#ifdef HAVE_DWFL_MODULE_BUILD_ID
34903488
int build_id_len = dwfl_module_build_id(mod, &build_id, &vaddr);
34913489
#else
34923490
int build_id_len = 0;

0 commit comments

Comments
 (0)