码迷,mamicode.com
首页 > 其他好文 > 详细

关于undefined referenced xxxx的另一种原因

时间:2015-06-16 11:00:28      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

通常遇到undefined referenced xxx主要是因为引用的函数未定义,或者是找不到类库.

本文介绍的是另外一种情况: 要引用的函数被类库hidden了. 主要原因是编译类库的时候采用了-fvisibility=hidden

GLOBAL_CFLAGS =   -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden

weeds@weeds-ThinkPad-T440p:~$ objdump -t libinternalcommon.a
In archive libinternalcommon.a:

socket.o: file format elf32-little

SYMBOL TABLE:
00000000 l df ABS 00000000 socket.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .mdebug.abi32 00000000 .mdebug.abi32
00000000 l O .bss 00000004 verbose
00000000 l d .rodata.str1.4 00000000 .rodata.str1.4
00000018 l O .rodata 00000010 func.4182
00000038 l O .rodata 00000014 func.4136
00000028 l O .rodata 0000000f func.4157
00000000 l O .rodata 00000017 func.4227
00000000 l d .rodata 00000000 .rodata
00000000 l .rodata.str1.4 00000000 LC000000024l.rodata.str1.400000000LC1
00000030 l .rodata.str1.4 00000000 LC20000003cl.rodata.str1.400000000LC3
00000054 l .rodata.str1.4 00000000 LC40000005cl.rodata.str1.400000000LC5
00000064 l .rodata.str1.4 00000000 LC60000006cl.rodata.str1.400000000LC7
00000080 l .rodata.str1.4 00000000 LC8000000a0l.rodata.str1.400000000LC9
000000b0 l .rodata.str1.4 00000000 LC10000000c4l.rodata.str1.400000000LC11
000000d0 l .rodata.str1.4 00000000 LC12000000e0l.rodata.str1.400000000LC13
000000e8 l .rodata.str1.4 00000000 LC14000000f4l.rodata.str1.400000000LC15
0000010c l .rodata.str1.4 00000000 LC1600000138l.rodata.str1.400000000LC17
00000140 l .rodata.str1.4 00000000 $LC18
00000000 l d .reginfo 00000000 .reginfo
00000000 l d .pdr 00000000 .pdr
00000000 l d .comment 00000000 .comment
00000000 l d .gnu.attributes 00000000 .gnu.attributes
00000000 g F .text 00000018 .hidden socket_set_verbose
00000000 O UND 00000000 _gp_disp
00000018 g F .text 00000278 .hidden socket_check_fd
00000000 UND 00000000 stderr
00000000 UND 00000000 fprintf
00000000 UND 00000000 select
00000000 UND 00000000 __errno_location
00000000 UND 00000000 strerror
00000290 g F .text 00000064 .hidden socket_accept
00000000 UND 00000000 accept
000002f4 g F .text 00000018 .hidden socket_shutdown
00000000 UND 00000000 shutdown
0000030c g F .text 00000018 .hidden socket_close
00000000 UND 00000000 close
00000324 g F .text 00000128 .hidden socket_create_unix
00000000 UND 00000000 unlink
00000000 UND 00000000 socket
00000000 UND 00000000 perror
00000000 UND 00000000 strncpy
00000000 UND 00000000 strlen
00000000 UND 00000000 bind
00000000 UND 00000000 listen
0000044c g F .text 00000220 .hidden socket_connect_unix
00000000 UND 00000000 stat
00000000 UND 00000000 connect
0000066c g F .text 0000017c .hidden socket_create
00000000 UND 00000000 setsockopt
000007e8 g F .text 00000224 .hidden socket_connect
00000000 UND 00000000 gethostbyname
00000a0c g F .text 000000f4 .hidden socket_receive_timeout
00000000 UND 00000000 recv
00000b00 g F .text 00000038 .hidden socket_receive
00000b38 g F .text 00000038 .hidden socket_peek
00000b70 g F .text 00000018 .hidden socket_send
00000000 UND 00000000 send

thread.o: file format elf32-little

SYMBOL TABLE:
00000000 l df ABS 00000000 thread.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .mdebug.abi32 00000000 .mdebug.abi32
00000000 l d .reginfo 00000000 .reginfo
00000000 l d .pdr 00000000 .pdr
00000000 l d .comment 00000000 .comment
00000000 l d .gnu.attributes 00000000 .gnu.attributes
00000000 g F .text 00000024 .hidden thread_new
00000000 O UND 00000000 _gp_disp
00000000 UND 00000000 pthread_create
00000024 g F .text 00000008 .hidden thread_free
0000002c g F .text 00000018 .hidden thread_join
00000000 UND 00000000 pthread_join
00000044 g F .text 00000018 .hidden mutex_init
00000000 UND 00000000 pthread_mutex_init
0000005c g F .text 00000018 .hidden mutex_destroy
00000000 UND 00000000 pthread_mutex_destroy
00000074 g F .text 00000018 .hidden mutex_lock
00000000 UND 00000000 pthread_mutex_lock
0000008c g F .text 00000018 .hidden mutex_unlock
00000000 UND 00000000 pthread_mutex_unlock
000000a4 g F .text 00000018 .hidden thread_once
00000000 UND 00000000 pthread_once

debug.o: file format elf32-little

SYMBOL TABLE:
00000000 l df ABS 00000000 debug.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .mdebug.abi32 00000000 .mdebug.abi32
00000000 l O .bss 00000004 debug_level
00000000 l d .rodata.str1.4 00000000 .rodata.str1.4
00000000 l .rodata.str1.4 00000000 LC00000000cl.rodata.str1.400000000LC1
0000001c l .rodata.str1.4 00000000 LC20000002cl.rodata.str1.400000000LC4
00000024 l .rodata.str1.4 00000000 LC300000030l.rodata.str1.400000000LC5
00000038 l .rodata.str1.4 00000000 LC600000040l.rodata.str1.400000000LC7
00000044 l .rodata.str1.4 00000000 LC800000060l.rodata.str1.400000000LC9
00000000 l d .reginfo 00000000 .reginfo
00000000 l d .pdr 00000000 .pdr
00000000 l d .comment 00000000 .comment
00000000 l d .gnu.attributes 00000000 .gnu.attributes
00000000 g F .text 00000018 .hidden internal_set_debug_level
00000000 O UND 00000000 _gp_disp
00000018 g F .text 0000017c .hidden debug_info_real
00000000 UND 00000000 vasprintf
00000000 UND 00000000 time
00000000 UND 00000000 malloc
00000000 UND 00000000 localtime
00000000 UND 00000000 strftime
00000000 UND 00000000 asprintf
00000000 UND 00000000 free
00000000 UND 00000000 printf
00000000 UND 00000000 puts
00000000 UND 00000000 stdout
00000000 UND 00000000 fflush
00000194 g F .text 000001c0 .hidden debug_buffer
00000000 UND 00000000 stderr
00000000 UND 00000000 fprintf
00000000 UND 00000000 fputs
00000000 UND 00000000 fputc
00000354 g F .text 000000b4 .hidden debug_buffer_to_file
00000000 UND 00000000 fopen
00000000 UND 00000000 fwrite
00000000 UND 00000000 fclose
00000408 g F .text 000000f0 .hidden debug_plist_real
00000000 UND 00000000 plist_to_xml

userpref.o: file format elf32-little

SYMBOL TABLE:
00000000 l df ABS 00000000 userpref.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .mdebug.abi32 00000000 .mdebug.abi32
00000000 l d .rodata.str1.4 00000000 .rodata.str1.4
00000000 l F .text 000000fc X509_add_ext_helper
00000000 l O .rodata 00000014 FUNCTION.13990
00000000 l O .bss 00000004 __config_dir
00000070 l O .rodata 00000018 FUNCTION.13928
00000054 l O .rodata 0000001a FUNCTION.13933
00000038 l O .rodata 0000001a FUNCTION.13953
00000014 l O .rodata 00000024 FUNCTION.14001
00000000 l d .rodata 00000000 .rodata
00000000 l .rodata.str1.4 00000000 LC00000000cl.rodata.str1.400000000LC1
00000038 l .rodata.str1.4 00000000 LC200000044l.rodata.str1.400000000LC3
00000048 l .rodata.str1.4 00000000 LC400000054l.rodata.str1.400000000LC5
00000084 l .rodata.str1.4 00000000 LC700000074l.rodata.str1.400000000LC6
00000090 l .rodata.str1.4 00000000 LC8000000b8l.rodata.str1.400000000LC9
000000c0 l .rodata.str1.4 00000000 LC10000000f4l.rodata.str1.400000000LC11
00000100 l .rodata.str1.4 00000000 LC1200000108l.rodata.str1.400000000LC13
0000012c l .rodata.str1.4 00000000 LC1400000140l.rodata.str1.400000000LC15
00000154 l .rodata.str1.4 00000000 LC1600000180l.rodata.str1.400000000LC17
000001a4 l .rodata.str1.4 00000000 LC18000001acl.rodata.str1.400000000LC19
000001ec l .rodata.str1.4 00000000 LC2000000200l.rodata.str1.400000000LC21
00000210 l .rodata.str1.4 00000000 LC2200000220l.rodata.str1.400000000LC23
00000230 l .rodata.str1.4 00000000 $LC24
00000000 l d .reginfo 00000000 .reginfo
00000000 l d .pdr 00000000 .pdr
00000000 l d .comment 00000000 .comment
00000000 l d .gnu.attributes 00000000 .gnu.attributes
00000000 O UND 00000000 _gp_disp
00000000 UND 00000000 X509V3_set_ctx
00000000 UND 00000000 X509V3_EXT_conf_nid
00000000 UND 00000000 debug_info_real
00000000 UND 00000000 X509_add_ext
00000000 UND 00000000 X509_EXTENSION_free
000000fc g F .text 0000010c .hidden userpref_get_config_dir
00000000 UND 00000000 strdup
00000000 UND 00000000 string_concat
00000000 UND 00000000 free
00000000 UND 00000000 strlen
00000208 g F .text 000000ac .hidden userpref_read_system_buid
00000000 UND 00000000 usbmuxd_read_buid
000002b4 g F .text 000000bc .hidden userpref_has_pair_record
00000000 UND 00000000 stat
00000370 g F .text 0000024c .hidden userpref_get_paired_udids
00000000 UND 00000000 opendir
00000000 UND 00000000 readdir
00000000 UND 00000000 strstr
00000000 UND 00000000 malloc
00000000 UND 00000000 strncpy
00000000 UND 00000000 closedir
000005bc g F .text 00000080 .hidden userpref_save_pair_record
00000000 UND 00000000 plist_to_bin
00000000 UND 00000000 usbmuxd_save_pair_record
0000063c g F .text 000000e4 .hidden userpref_read_pair_record
00000000 UND 00000000 usbmuxd_read_pair_record
00000000 UND 00000000 memcmp
00000000 UND 00000000 plist_from_bin
00000000 UND 00000000 plist_from_xml
00000720 g F .text 0000003c .hidden userpref_delete_pair_record
00000000 UND 00000000 usbmuxd_delete_pair_record
0000075c g F .text 00000080 .hidden pair_record_get_host_id
00000000 UND 00000000 plist_dict_get_item
00000000 UND 00000000 plist_get_node_type
00000000 UND 00000000 plist_get_string_val
000007dc g F .text 0000005c .hidden pair_record_set_host_id
00000000 UND 00000000 plist_new_string
00000000 UND 00000000 plist_dict_set_item
00000838 g F .text 0000012c .hidden pair_record_get_item_as_key_data
00000000 UND 00000000 plist_get_data_val
00000000 UND 00000000 memcpy
00000964 g F .text 00000024 .hidden pair_record_import_key_with_name
00000988 g F .text 00000024 .hidden pair_record_import_crt_with_name
000009ac g F .text 0000007c .hidden pair_record_set_item_from_key_data
00000000 UND 00000000 plist_new_data
00000a28 g F .text 00000c38 .hidden pair_record_generate_keys_and_certs
00000000 UND 00000000 BN_new
00000000 UND 00000000 RSA_new
00000000 UND 00000000 BN_set_word
00000000 UND 00000000 RSA_generate_key_ex
00000000 UND 00000000 BN_free
00000000 UND 00000000 EVP_PKEY_new
00000000 UND 00000000 EVP_PKEY_assign
00000000 UND 00000000 X509_new
00000000 UND 00000000 ASN1_INTEGER_new
00000000 UND 00000000 ASN1_INTEGER_set
00000000 UND 00000000 X509_set_serialNumber
00000000 UND 00000000 ASN1_INTEGER_free
00000000 UND 00000000 X509_set_version
00000000 UND 00000000 ASN1_TIME_new
00000000 UND 00000000 time
00000000 UND 00000000 ASN1_TIME_set
00000000 UND 00000000 X509_set_notBefore
00000000 UND 00000000 X509_set_notAfter
00000000 UND 00000000 ASN1_TIME_free
00000000 UND 00000000 X509_set_pubkey
00000000 UND 00000000 EVP_sha1
00000000 UND 00000000 X509_sign
00000000 UND 00000000 BIO_new_mem_buf
00000000 UND 00000000 BIO_s_mem
00000000 UND 00000000 BIO_new
00000000 UND 00000000 PEM_write_bio_X509
00000000 UND 00000000 BIO_ctrl
00000000 UND 00000000 BIO_free
00000000 UND 00000000 PEM_write_bio_PrivateKey
00000000 UND 00000000 PEM_read_bio_RSAPublicKey
00000000 UND 00000000 EVP_PKEY_free
00000000 UND 00000000 X509V3_EXT_cleanup
00000000 UND 00000000 X509_free

utils.o: file format elf32-little

SYMBOL TABLE:
00000000 l df ABS 00000000 utils.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .mdebug.abi32 00000000 .mdebug.abi32
00000000 l d .rodata.str1.4 00000000 .rodata.str1.4
00000000 l F .text 00000478 plist_node_print_to_stream
00000024 l O .rodata 00000041 base64_str
0000062c l F .text 00000118 plist_array_print_to_stream
00000478 l F .text 000001b4 plist_dict_print_to_stream
00000000 l d .rodata.cst8 00000000 .rodata.cst8
00000000 l d .rodata 00000000 .rodata
00000000 l .rodata.str1.4 00000000 LC000000008l.rodata.str1.400000000LC1
00000010 l .rodata.str1.4 00000000 LC200000014l.rodata.str1.400000000LC3
0000001c l .rodata.str1.4 00000000 LC400000020l.rodata.str1.400000000LC5
00000028 l .rodata.str1.4 00000000 LC60000003cl.rodata.str1.400000000LC7
00000040 l .rodata.str1.4 00000000 LC800000044l.rodata.str1.400000000LC9
0000004c l .rodata.str1.4 00000000 LC1000000050l.rodata.str1.400000000LC11
00000058 l .rodata.str1.4 00000000 LC1200000000l.rodata.cst800000000LC14
0000005c l .rodata.str1.4 00000000 LC1300000008l.rodata.cst800000000LC16
00000068 l .rodata.str1.4 00000000 LC1500000010l.rodata.cst800000000LC18
00000074 l .rodata.str1.4 00000000 LC1700000018l.rodata.cst800000000LC20
00000080 l .rodata.str1.4 00000000 LC190000008cl.rodata.str1.400000000LC21
00000098 l .rodata.str1.4 00000000 LC22000000acl.rodata.str1.400000000LC23
000000b0 l .rodata.str1.4 00000000 LC24000000b4l.rodata.str1.400000000LC25
00000000 l d .reginfo 00000000 .reginfo
00000000 l d .pdr 00000000 .pdr
00000000 l d .comment 00000000 .comment
00000000 l d .gnu.attributes 00000000 .gnu.attributes
00000000 O UND 00000000 _gp_disp
00000000 UND 00000000 plist_get_node_type
00000000 UND 00000000 plist_get_bool_val
00000000 UND 00000000 fprintf
00000000 UND 00000000 plist_get_uint_val
00000000 UND 00000000 plist_get_real_val
00000000 UND 00000000 plist_get_string_val
00000000 UND 00000000 plist_get_key_val
00000000 UND 00000000 plist_get_data_val
00000000 UND 00000000 malloc
00000000 UND 00000000 free
00000000 UND 00000000 fputc
00000000 UND 00000000 plist_get_date_val
00000000 UND 00000000 localtime
00000000 UND 00000000 strftime
00000000 UND 00000000 plist_dict_new_iter
00000000 UND 00000000 plist_dict_next_item
00000000 UND 00000000 fputs
00000000 UND 00000000 plist_array_get_size
00000000 UND 00000000 plist_array_get_item
00000744 g F .text 00000100 .hidden string_concat
00000000 UND 00000000 strlen
00000000 UND 00000000 stpcpy
00000844 g F .text 0000011c .hidden string_build_path
00000000 UND 00000000 strcpy
00000000 UND 00000000 strcat
00000000 O UND 00000000 __floatundidf
00000000 O UND 00000000 __divdf3
00000960 g F .text 000001c8 .hidden string_format_size
00000000 UND 00000000 sprintf
00000000 UND 00000000 strdup
00000b28 g F .text 00000098 .hidden string_toupper
00000000 UND 00000000 __ctype_toupper
00000bc0 g F .text 0000010c .hidden generate_uuid
00000000 UND 00000000 time
00000000 UND 00000000 srand
00000000 UND 00000000 rand
00000ccc g F .text 0000014c .hidden buffer_read_from_filename
00000000 UND 00000000 fopen
00000000 UND 00000000 fseek
00000000 UND 00000000 ftell
00000000 UND 00000000 rewind
00000000 UND 00000000 fclose
00000000 UND 00000000 fread
00000e18 g F .text 0000009c .hidden buffer_write_to_filename
00000000 UND 00000000 fwrite
00000eb4 g F .text 000000e8 .hidden plist_read_from_filename
00000000 UND 00000000 plist_from_xml
00000000 UND 00000000 memcmp
00000000 UND 00000000 plist_from_bin
00000f9c g F .text 000000a8 .hidden plist_write_to_filename
00000000 UND 00000000 plist_to_xml
00000000 UND 00000000 plist_to_bin
00001044 g F .text 000000a4 .hidden plist_print_to_stream

修复此问题, 需要取出编译选项.但是我去掉之后,仍然没有正常工作,在我发现即使可以正常编译也无法满足我的需求的时候,我暂停了尝试, 你如果有需要可以试试.

关于undefined referenced xxxx的另一种原因

标签:

原文地址:http://blog.csdn.net/qianguozheng/article/details/46515511

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!