radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.34k stars 2.97k forks source link

Error compile for MacOS 10.7.5: Undefined symbols for architecture x86_64 #8349

Closed SieuDoTia closed 6 years ago

SieuDoTia commented 7 years ago

Get error when compile for MacOS 10.7.5:

Undefined symbols for architecture x86_64: "_environ", referenced from: _r_sys_clearenv in sys.o (maybe you meant: _r_sys_set_environ, _r_sys_get_environ ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: [libr_util.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

I compile release 1.6.0 use Recommended Install from Git. System information: • Mac OS X 10.7.5 • clang Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) • GNU make 3.81 • gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) • Intel Core Duo 2.16 GHz - MacBook 2007

radare commented 7 years ago

Is this r2 from git or 1.6?

On 28 Aug 2017, at 01:38, SieuDoTia notifications@github.com wrote:

Get error when compile for MacOS 10.7.5:

Undefined symbols for architecture x86_64: "_environ", referenced from: _r_sys_clearenv in sys.o (maybe you meant: _r_sys_set_environ, _r_sys_get_environ ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: [libr_util.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

I compile release 1.6.0 use Recommended Install from Git. System information: • Mac OS X 10.7.5 • clang Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) • GNU make 3.81 • gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) • Intel Core Duo 2.16 GHz - MacBook 2007

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

SieuDoTia commented 7 years ago

radare2 from git, version 1.6

SieuDoTia commented 7 years ago

Output of r2 -v is: -bash: r2: command not found

Can't compile, not have r2 command.

Maijin commented 7 years ago

yes sorry misread

wargio commented 7 years ago

how do you build it?

SieuDoTia commented 7 years ago

Use recommended Install from Git at http://www.radare.org/r/down.html: git clone https://github.com/radare/radare2 cd radare2 sys/install.sh # just run this script to update r2 from git

radare commented 7 years ago

I build r2 without any issues on mac 10.12 and 10.4, i dont have any 10.7 to test

SieuDoTia commented 7 years ago

Compete compile result before error (can't attach file beacuse GitHub not support browser for Mac OS X 10.7): sys/install.sh WARNING: Updating from remote repository remote: Counting objects: 270, done. remote: Total 270 (delta 226), reused 226 (delta 226), pack-reused 44 Receiving objects: 100% (270/270), 115.09 KiB, done. Resolving deltas: 100% (227/227), completed with 86 local objects. From https://github.com/radare/radare2 041e624..6eef80c master -> origin/master Updating 041e624..6eef80c Fast-forward binr/radare2/radare2.c | 18 ++++++---- libr/anal/anal.c | 1 - libr/anal/anal_ex.c | 2 +- libr/anal/fcn.c | 8 +---- libr/anal/flirt.c | 5 ++- libr/anal/p/anal_arm_cs.c | 3 ++ libr/anal/p/anal_java.c | 6 +++- libr/asm/arch/z80/z80asm.c | 9 +++++ libr/asm/asm.c | 1 + libr/bin/bin.c | 9 +++++ libr/bin/d/Makefile | 2 +- libr/bin/d/dll/wsnmp32.sdb.txt | 51 ++++++++++++++++++++++++++++ libr/bin/p/bin_dex.c | 2 +- libr/bin/p/bin_xtr_dyldcache.c | 2 +- libr/bin/pdb/tpi.c | 2 +- libr/core/anal_vt.c | 8 +++-- libr/core/canal.c | 4 +-- libr/core/cbin.c | 6 ++-- libr/core/cmd.c | 5 +-- libr/core/cmd_anal.c | 23 +++++-------- libr/core/cmd_open.c | 14 ++++---- libr/core/cmd_print.c | 54 +++++++++++++----------------- libr/core/cmd_search.c | 29 +++------------- libr/core/cmd_search_rop.c | 1 + libr/core/cmd_zign.c | 6 ++-- libr/core/file.c | 9 ++++- libr/core/graph.c | 6 ++-- libr/debug/p/debug_gdb.c | 11 ++++-- libr/debug/p/native/linux/linux_coredump.c | 8 +++-- libr/include/r_bin.h | 4 +++ libr/include/r_io.h | 5 +-- libr/include/r_socket.h | 1 - libr/include/r_types.h | 7 ++-- libr/include/r_userconf.h.acr | 4 +++ libr/io/io.c | 4 +-- libr/io/map.c | 5 +-- libr/io/meson.build | 2 +- libr/io/p/io_gdb.c | 17 ++++++---- libr/io/p/io_r2k_linux.c | 27 ++++++++------- libr/io/p/io_zip.c | 16 +++++---- libr/io/section.c | 2 +- libr/search/search.c | 21 +++++------- libr/socket/socket.c | 8 ++--- libr/syscall/syscall.c | 8 +++-- libr/util/file.c | 6 ++-- libr/util/meson.build | 1 + libr/util/rbtree.c | 52 ++++++++++++++-------------- shlr/Makefile | 2 +- shlr/gdb/src/gdbclient/xml.c | 23 ++++++++++++- shlr/java/class.c | 7 ++-- shlr/sdb/msvc/unistd.h | 2 ++ 51 files changed, 320 insertions(+), 209 deletions(-) create mode 100644 libr/bin/d/dll/wsnmp32.sdb.txt create mode 100644 shlr/sdb/msvc/unistd.h

export USE_R2_CAPSTONE=

configure-plugins: Loading ./plugins.cfg .. configure-plugins: Generating libr/config.h .. configure-plugins: Generating libr/config.mk .. SHARED: io.shm STATIC: anal.6502 anal.8051 anal.arc anal.arm_cs anal.arm_gnu anal.avr anal.bf anal.cr16 anal.cris anal.dalvik anal.ebc anal.gb anal.h8300 anal.i4004 anal.i8080 anal.java anal.m68k_cs anal.malbolge anal.mips_cs anal.mips_gnu anal.msp430 anal.nios2 anal.null anal.pic18c anal.ppc_cs anal.ppc_gnu anal.riscv anal.rsp anal.sh anal.snes anal.sparc_cs anal.sparc_gnu anal.sysz anal.tms320 anal.v810 anal.v850 anal.vax anal.ws anal.x86_cs anal.x86_udis anal.xap anal.xcore_cs anal.xtensa anal.z80 asm.6502 asm.8051 asm.arc asm.arm_as asm.arm_cs asm.arm_gnu asm.arm_winedbg asm.avr asm.bf asm.cr16 asm.cris_gnu asm.dalvik asm.dcpu16 asm.ebc asm.evm asm.gb asm.h8300 asm.hexagon_gnu asm.hppa_gnu asm.i4004 asm.i8080 asm.java asm.lanai_gnu asm.lh5801 asm.lm32 asm.m68k_cs asm.malbolge asm.mcs96 asm.mips_cs asm.mips_gnu asm.msp430 asm.nios2 asm.pic18c asm.ppc_cs asm.ppc_gnu asm.riscv asm.rsp asm.sh asm.snes asm.sparc_cs asm.sparc_gnu asm.spc700 asm.sysz asm.tms320 asm.tricore asm.v810 asm.v850 asm.vax asm.wasm asm.ws asm.x86_as asm.x86_cs asm.x86_nasm asm.x86_nz asm.x86_udis asm.xap asm.xcore_cs asm.xtensa asm.z80 bin.any bin.art bin.avr bin.bf bin.bflt bin.bios bin.bootimg bin.cgc bin.coff bin.dex bin.dol bin.dyldcache bin.elf bin.elf64 bin.fs bin.java bin.mach0 bin.mach064 bin.mbn bin.menuet bin.mz bin.nes bin.nin3ds bin.ninds bin.ningb bin.ningba bin.nro bin.omf bin.p9 bin.pe bin.pe64 bin.pebble bin.psxexe bin.sfc bin.smd bin.sms bin.spc700 bin.te bin.vsf bin.wasm bin.xbe bin.zimg bin_xtr.fatmach0 bin_xtr.xtr_dyldcache bp.arm bp.bf bp.mips bp.ppc bp.x86 core.anal core.java crypto.aes crypto.aes_cbc crypto.base64 crypto.base91 crypto.blowfish crypto.cps2 crypto.des crypto.punycode crypto.rc2 crypto.rc4 crypto.rc6 crypto.rol crypto.ror crypto.rot crypto.xor debug.bf debug.bochs debug.esil debug.gdb debug.io debug.native debug.qnx debug.rap debug.windbg egg.exec egg.xor fs.ext2 fs.fat fs.fb fs.hfs fs.hfsplus fs.iso9660 fs.jfs fs.minix fs.ntfs fs.posix fs.reiserfs fs.sfs fs.squash fs.tar fs.udf fs.ufs fs.xfs io.ar io.bfdbg io.bochs io.debug io.default io.gdb io.gzip io.http io.ihex io.mach io.malloc io.mmap io.null io.procpid io.ptrace io.qnx io.r2k io.r2pipe io.r2web io.rap io.rbuf io.self io.shm io.sparse io.tcp io.w32 io.w32dbg io.windbg io.zip lang.vala parse.6502_pseudo parse.arm_pseudo parse.att2intel parse.avr_pseudo parse.dalvik_pseudo parse.m68k_pseudo parse.mips_pseudo parse.mreplace parse.ppc_pseudo parse.sh_pseudo parse.x86_pseudo cp: plugins.cfg and ./plugins.cfg are identical (not copied). checking build system type... i386-unknown-darwin checking host system type... i386-unknown-darwin checking target system type... i386-unknown-darwin checking for working directories... current using prefix '/usr/local' checking for c compiler... gcc checking for dynamic library... required checking for patch... /usr/bin/patch checking for git... /usr/bin/git checking for libmagic ... no Using PKGCONFIG: pkg-config checking pkg-config flags for capstone... no checking for libz ... yes checking for libzip ... no checking for libssl ... yes Using PKGCONFIG: pkg-config checking pkg-config flags for openssl... no creating ./config-user.mk creating libr/include/r_userconf.h creating pkgcfg/r_io.pc creating pkgcfg/r_magic.pc creating pkgcfg/r_asm.pc creating pkgcfg/r_bin.pc creating pkgcfg/r_anal.pc creating pkgcfg/r_hash.pc creating pkgcfg/r_cons.pc creating pkgcfg/r_core.pc creating pkgcfg/r_lang.pc creating pkgcfg/r_socket.pc creating pkgcfg/r_debug.pc creating pkgcfg/r_reg.pc creating pkgcfg/r_config.pc creating pkgcfg/r_flag.pc creating pkgcfg/r_syscall.pc creating pkgcfg/r_util.pc creating pkgcfg/r_search.pc creating pkgcfg/r_bp.pc creating pkgcfg/r_parse.pc creating pkgcfg/r_fs.pc cleaning temporally files... done

Final report:

Maijin commented 7 years ago

Use pastebin or similar service or drag and drop files here to attach them.

wargio commented 7 years ago

@radare maybe it's the same bug patched here: https://github.com/radare/radare2/commit/5bdbfd240a00bb372a272d6a2fd844e8f1fd9325

radare commented 7 years ago

this was 2 years ago.. i cant reproduce the issue, but maybe it makes sense that this old mac required linking against a framework to get the environment exposed by libSystem

radare commented 7 years ago

in fact this is already done and stored in 'env' instead of accessing 'environ'.. let me try to do a quick blind fix..

radare commented 7 years ago

please try again

SieuDoTia commented 7 years ago

Same error again: LD libr_util.dylib Undefined symbols for architecture x86_64: "_environ", referenced from: _r_sys_clearenv in sys.o (maybe you meant: _r_sys_set_environ, _r_sys_get_environ ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: [libr_util.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

SieuDoTia commented 7 years ago

If can send me compile binary files for 10.4, may be it will work for 10.7. Please no install package, just binary files.

radare commented 7 years ago

is build not working yet?

On 6 Sep 2017, at 03:27, SieuDoTia notifications@github.com wrote:

If can send me compile binary files for 10.4, may be it will work for 10.7. Please no install package, just binary files.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/radare/radare2/issues/8349#issuecomment-327347926, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3-luh_XLUGoRDSVV1JhH1B74dn5Wagks5sffUNgaJpZM4PD9Nu.

SieuDoTia commented 7 years ago

If can compile I will tell you guys

Maijin commented 6 years ago

Status?

XVilka commented 6 years ago

@SieuDoTia ping?

SieuDoTia commented 6 years ago

Use recommended Install from Git at http://www.radare.org/r/down.html Error:

rbtree.c:74: warning: ‘_check’ defined but not used json_indent.c: In function ‘r_print_json_path’: json_indent.c:130: warning: cast from pointer to integer of different size LD libr_util.dylib Undefined symbols for architecture x86_64: "_environ", referenced from: _r_sys_clearenv in sys.o (maybe you meant: _r_sys_set_environ, _r_sys_get_environ ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: [libr_util.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

radare commented 6 years ago

Fixing this with a mac 10.7.5 takes like 5 minutes. Can u please send a pr fixing this? Its just adding the proper ifdef around the haveenviron variable. I dont have time right now to setup the old mac instalation. Also. Is there any hw that runs 10.7 and have no updates?

On 2 Nov 2017, at 08:28, SieuDoTia notifications@github.com wrote:

Use recommended Install from Git at http://www.radare.org/r/down.html Error:

rbtree.c:74: warning: ‘_check’ defined but not used json_indent.c: In function ‘r_print_json_path’: json_indent.c:130: warning: cast from pointer to integer of different size LD libr_util.dylib Undefined symbols for architecture x86_64: "_environ", referenced from: _r_sys_clearenv in sys.o (maybe you meant: _r_sys_set_environ, _r_sys_get_environ ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: [libr_util.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

SieuDoTia commented 6 years ago

Please tell me which shell file need fix? I guess one file in /pkgcfg but not know which file. Thanks!

radare commented 6 years ago

No, pkgconfig have nothing to in this story..

See libr/util/sys.c and search for ‘env’, ‘environ’ and ‘HAVE_ENVIRON'

On 4 Nov 2017, at 08:02, SieuDoTia notifications@github.com wrote:

Please tell me which shell file need fix? I guess one file in /pkgcfg but not know which file. Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/radare/radare2/issues/8349#issuecomment-341876977, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3-lvGk2d97BGf8EW75tWGvBLyu1NCkks5szAwggaJpZM4PD9Nu.

SieuDoTia commented 6 years ago

I try this (but still have same error):

if APPLE

include

ifdef MAC_10_7 || MAC_10_8

define HAVE_ENVIRON 1

else

define HAVE_ENVIRON 0

endif

radare commented 6 years ago

Macos10.7 doesnt have environ thats why. It should use the api method. That is used for mac 10.4 where i can build it

On 5 Nov 2017, at 01:01, SieuDoTia notifications@github.com wrote:

I try this (but still have same error):

if APPLE

include

ifdef MAC_10_7 || MAC_10_8

define HAVE_ENVIRON 1

else

define HAVE_ENVIRON 0

endif

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

radare commented 6 years ago

Fixed in fe649cf4e379eb128b8b01843cbc2443c61f86ee