radareorg / radare2

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

Error during install - libr/config.mk:12: warning: NUL character seen; rest of line ignored #20572

Closed robertoll closed 2 years ago

robertoll commented 2 years ago

Description

❯ radare2/sys/install.sh
/home/roberto/Desktop/radare2
WARNING: Updating from remote repository
From https://github.com/radareorg/radare2
 * branch                master     -> FETCH_HEAD
Already up to date.
Warning: Cannot find system wide capstone
[*] Finding gmake is a tracked alias for /usr/bin/gmake OK
[*] Configuring the build system ... OK
[*] Checking out capstone... /bin/sh ./sys/build.sh
/home/roberto/Desktop/radare2
Building on Linux : computing number of allowed parallel jobs.
Maximum allowed RAM memory per job is 150000 kB.
Number of CPUs is 4 and current free RAM allows us to run 39 jobs in parallel.
So, the build will run on 4 job(s).
/home/roberto/Desktop/radare2
configure-plugins: Loading ./plugins.cfg ..
configure-plugins: Generating libr/config.h
configure-plugins: Generating libr/asm/d/config.inc
configure-plugins: Generating libr/config.mk
SHARED: io.shm
STATIC: anal.6502 anal.6502_cs anal.8051 anal.alpha anal.amd29k anal.arc anal.arm_cs anal.arm_gnu anal.arm_v35 anal.avr anal.bf anal.bpf anal.bpf_cs anal.chip8 anal.cr16 anal.cris anal.dalvik anal.ebc anal.evm_cs anal.gb anal.h8300 anal.i4004 anal.i8080 anal.java anal.jdh8 anal.kvx anal.lh5801 anal.lm32 anal.loongarch_gnu anal.m680x_cs anal.m68k_cs anal.malbolge anal.mcore anal.mcs96 anal.mips_cs anal.mips_gnu anal.msp430 anal.nios2 anal.null anal.or1k anal.pdp11_gnu anal.pic anal.pickle anal.ppc_cs anal.ppc_gnu anal.propeller anal.pyc anal.riscv anal.riscv_cs anal.rsp anal.s390_cs anal.s390_gnu anal.sh anal.snes anal.sparc_cs anal.sparc_gnu anal.tms320 anal.tricore anal.v810 anal.v850 anal.vax anal.wasm anal.ws anal.x86_cs anal.xap anal.xcore_cs anal.xtensa anal.z80 asm.arm_as asm.arm_cs asm.arm_gnu asm.arm_winedbg asm.hppa_gnu asm.lanai_gnu asm.m68k_gnu asm.null asm.or1k asm.ppc_as asm.ppc_cs asm.sparc_gnu asm.vasm asm.x86_as asm.x86_nasm asm.x86_nz bin.any bin.art bin.avr bin.bf bin.bflt bin.bios bin.bootimg bin.cgc bin.coff bin.dex bin.dmp64 bin.dol bin.dyldcache bin.elf bin.elf64 bin.fs bin.hunk bin.java bin.le bin.mach0 bin.mach064 bin.mbn bin.mdmp bin.menuet bin.msx bin.mz bin.ne bin.nes bin.nin3ds bin.ninds bin.ningb bin.ningba bin.nro bin.nso bin.off bin.omf bin.p9 bin.pe bin.pe64 bin.pebble bin.prg bin.psxexe bin.pyc bin.qnx bin.s390 bin.sfc bin.smd bin.sms bin.symbols bin.te bin.tic bin.vsf bin.wad bin.wasm bin.xbe bin.xnu_kernelcache bin.z64 bin.zimg bin_ldr.ldr_linux bin_xtr.xtr_dyldcache bin_xtr.xtr_fatmach0 bin_xtr.xtr_pemixed bin_xtr.xtr_sep64 bin_xtr.xtr_xalz bp.arm bp.bf bp.mips bp.ppc bp.x86 core.a2f core.java core.sixref crypto.aes crypto.aes_cbc crypto.aes_wrap 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.serpent crypto.sm4 crypto.xor debug.bf debug.bochs debug.esil debug.gdb debug.io debug.native debug.null debug.qnx debug.rap debug.winkd egg.exec egg.xor esil.dummy fs.ext2 fs.fat fs.fb fs.hfs fs.hfsplus fs.io fs.iso9660 fs.jfs fs.minix fs.ntfs fs.posix fs.r2 fs.reiserfs fs.sfs fs.tar fs.udf fs.ufs fs.xfs io.ar io.bfdbg io.bochs io.debug io.default io.fd io.gdb io.gprobe io.gzip io.http io.ihex io.isotp 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.socket io.sparse io.tcpslurp io.w32 io.w32dbg io.winedbg io.winkd io.xalz io.zip lang.c lang.cpipe lang.pipe lang.rust lang.spp lang.v lang.vala lang.zig parse.6502_pseudo parse.arm_pseudo parse.att2intel parse.avr_pseudo parse.chip8_pseudo parse.dalvik_pseudo parse.m68k_pseudo parse.mips_pseudo parse.ppc_pseudo parse.riscv_pseudo parse.sh_pseudo parse.tms320_pseudo parse.v850_pseudo parse.wasm_pseudo parse.x86_pseudo parse.z80_pseudo
cp: './plugins.cfg' and 'plugins.cfg' are the same file
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for working directories... current
using prefix '/usr/local'
checking for c compiler... gcc
checking for dynamic library... required
checking for pkg-config... /usr/bin/pkg-config
checking for patch... /usr/bin/patch
checking for ar... /usr/bin/ar
checking for git... /usr/bin/git
checking for gperf... no
checking for libmagic ... no
checking pkg-config flags for liblz4... no
checking for libz ... yes
checking for libzip ... no
checking for libxxhash ... no
checking declaration of ADDR_NO_RANDOMIZE in sys/personality.h... yes
checking declaration of __GLIBC__ in features.h... yes
checking function arc4random_uniform() in c... no
checking function explicit_bzero() in c... yes
checking function explicit_memset() in c... no
checking function clock_nanosleep() in c... yes
checking function sigaction() in c... yes
checking function clock_gettime() in c... yes
checking cflags  -std=gnu99... yes
checking for libssl ... yes
checking pkg-config flags for openssl... yes
checking version of library libuv >= 1.0.0... ok
checking pkg-config flags for libuv... yes
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
creating pkgcfg/r_egg.pc
creating pkgcfg/r_crypto.pc
cleaning temporally files... done

Final report:
 - BUILD = x86_64-unknown-linux-gnu
 - CC = gcc
 - CFLAGS = ""
 - DEBUGGER = 1
 - HAVE_ARC4RANDOM_UNIFORM = 0
 - HAVE_EXPLICIT_BZERO = 1
 - HAVE_EXPLICIT_MEMSET = 0
 - HAVE_FORK = 1
 - HAVE_GPERF = 0
 - HAVE_LIBUV = 1
 - HAVE_LIB_GMP = 0
 - HAVE_OPENSSL = 0
 - HAVE_PTRACE = 1
 - HOST = x86_64-unknown-linux-gnu
 - LDFLAGS = -Wl,--as-needed 
 - LIBVERSION = 5.7.7
 - PKGCONFIG = /usr/bin/pkg-config
 - PREFIX = /usr/local
 - R_CHECKS_LEVEL = 2
 - TARGET = x86_64-unknown-linux-gnu
 - USERCC = gcc
 - USEROSTYPE = gnulinux
 - USE_CAPSTONE = 0
 - USE_LIB_MAGIC = 0
 - USE_LIB_XXHASH = 0
 - USE_LIB_ZIP = 0
 - USE_PTRACE_WRAP = 1
 - USE_SYSLZ4 = 0
 - VERSION = 5.7.7
 - WANT_DYLINK = 1
libr/config.mk:12: warning: NUL character seen; rest of line ignored
libr/config.mk:13: warning: NUL character seen; rest of line ignored
libr/config.mk:14: warning: NUL character seen; rest of line ignored
libr/config.mk:15: warning: NUL character seen; rest of line ignored
libr/config.mk:16: warning: NUL character seen; rest of line ignored
libr/config.mk:17: warning: NUL character seen; rest of line ignored
libr/config.mk:18: warning: NUL character seen; rest of line ignored
libr/config.mk:19: warning: NUL character seen; rest of line ignored
libr/config.mk:20: warning: NUL character seen; rest of line ignored
libr/config.mk:21: warning: NUL character seen; rest of line ignored
libr/config.mk:22: warning: NUL character seen; rest of line ignored
libr/config.mk:23: warning: NUL character seen; rest of line ignored
libr/config.mk:24: warning: NUL character seen; rest of line ignored
libr/config.mk:25: warning: NUL character seen; rest of line ignored
libr/config.mk:26: warning: NUL character seen; rest of line ignored
libr/config.mk:27: warning: NUL character seen; rest of line ignored
libr/config.mk:28: warning: NUL character seen; rest of line ignored
libr/config.mk:29: warning: NUL character seen; rest of line ignored
libr/config.mk:30: warning: NUL character seen; rest of line ignored
libr/config.mk:31: warning: NUL character seen; rest of line ignored
libr/config.mk:32: warning: NUL character seen; rest of line ignored
libr/config.mk:33: warning: NUL character seen; rest of line ignored
libr/config.mk:34: warning: NUL character seen; rest of line ignored
libr/config.mk:35: warning: NUL character seen; rest of line ignored
libr/config.mk:36: warning: NUL character seen; rest of line ignored
libr/config.mk:37: warning: NUL character seen; rest of line ignored
libr/config.mk:38: warning: NUL character seen; rest of line ignored
libr/config.mk:39: warning: NUL character seen; rest of line ignored
libr/config.mk:40: warning: NUL character seen; rest of line ignored
libr/config.mk:41: warning: NUL character seen; rest of line ignored
libr/config.mk:42: warning: NUL character seen; rest of line ignored
libr/config.mk:43: warning: NUL character seen; rest of line ignored
libr/config.mk:44: warning: NUL character seen; rest of line ignored
libr/config.mk:45: warning: NUL character seen; rest of line ignored
libr/config.mk:46: *** missing separator.  Stop.

I opened config.mk with vim, and there's a never ending line 12 with the strange characters, other lines seem fine, deleted the line and now got the following instead of NUL character:

- VERSION = 5.7.7
- WANT_DYLINK = 1
libr/config.mk:47: Data/radare2/libr/../mk/gcc.mk: No such file or directory
gmake: *** No rule to make target 'Data/radare2/libr/../mk/gcc.mk'.  Stop.

Any idea why this is happening? Tried searching with no avail. Any help is welcome, thanks.

trufae commented 2 years ago

cd radare2; sys/install.sh

do this line work? The line you used should work too, but its just to confirm a theory. Also do mk/gcc.mk exists? Looks like your copy of the source is missing some files?

robertoll commented 2 years ago

Tried going into the directory and running sys/install.sh, but same issue.

The mk/gcc.mk exists, I git cloned from https://github.com/radareorg/radare2 several times after removing the directory, same issue.

Found out there was something after the strangely encoded characters with VSCodium, this is line 12 after deleting strange characters:

STATIC_ANAL_PLUGINS= p/6502.mk p/6502_cs.mk p/8051.mk p/alpha.mk p/amd29k.mk p/arc.mk p/arm_cs.mk p/arm_gnu.mk p/arm_v35.mk p/avr.mk p/bf.mk p/bpf.mk p/bpf_cs.mk p/chip8.mk p/cr16.mk p/cris.mk p/dalvik.mk p/ebc.mk p/evm_cs.mk p/gb.mk p/h8300.mk p/i4004.mk p/i8080.mk p/java.mk p/jdh8.mk p/kvx.mk p/lh5801.mk p/lm32.mk p/loongarch_gnu.mk p/m680x_cs.mk p/m68k_cs.mk p/malbolge.mk p/mcore.mk p/mcs96.mk p/mips_cs.mk p/mips_gnu.mk p/msp430.mk p/nios2.mk p/null.mk p/or1k.mk p/pdp11_gnu.mk p/pic.mk p/pickle.mk p/ppc_cs.mk p/ppc_gnu.mk p/propeller.mk p/pyc.mk p/riscv.mk p/riscv_cs.mk p/rsp.mk p/s390_cs.mk p/s390_gnu.mk p/sh.mk p/snes.mk p/sparc_cs.mk p/sparc_gnu.mk p/tms320.mk p/tricore.mk p/v810.mk p/v850.mk p/vax.mk p/wasm.mk p/ws.mk p/x86_cs.mk p/xap.mk p/xcore_cs.mk p/xtensa.mk p/z80.mk

But I'm still getting:

libr/config.mk:47: Data/radare2/libr/../mk/gcc.mk: No such file or directory
gmake: *** No rule to make target 'Data/radare2/libr/../mk/gcc.mk'.  Stop.

The strange thing here is that Data is not the directory where radare2 is placed. There must be something writing a badly encoded character during the generation of the config.mk:

configure-plugins: Generating libr/config.mk

I've looked at configure-plugins where config.mk is generated, but can't see anything wrong, it seems it reads the libr/config.mk.head, libr/config.mk.tail, and in the middle it runs the following code:

generate_configmk () {
  splugins=""
  plugins=""
  oldlib=""
  for a in `echo "${STATIC} ${SHARED}" | tr " " "\n" | sort` ; do
    lib=$(echo $a | cut -d . -f 1) # library
    plg=$(echo $a | cut -d . -f 2) # plugin name
    if [ ! "$oldlib" = "$lib" ]; then
      [ -n "$oldlib" ] && printf "\n"
      oldlib=$lib
      uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
      printf "STATIC_${uclib}_PLUGINS="
      plugins="${plugins} __${uclib}"
    fi
    printf " p/${plg}.mk"
  done

  echo

  for a in ${SHARED} ; do
    lib=$(echo $a | cut -d . -f 1) # library
    plg=$(echo $a | cut -d . -f 2) # plugin name
    uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
    if [ -z "`echo ${splugins} | grep __${uclib}`" ]; then
      splugins="${splugins} __${uclib}"
      printf "SHARED_${uclib}_TARGETS="
    fi
    printf " p/io_${plg}.${EXT}"
  done
  echo
}

I'm almost certain that it's when it starts writing the plugins part that is corrupting the config.mk file, because the head and tail parts seem identical, it just copies them on the file.

I'm about to give up and look for another tool to debug ELF files

trufae commented 2 years ago

Use the meson build system or the release builds or r2env. I have never seen or reproduced any of the problems you are having so its hard to say whats going on.

are you using a posix shell?

trufae commented 2 years ago

Which version of gnu make do you use?

trufae commented 2 years ago

Wtf is "Data"? Do your builddir have spaces in the path? Gnu make cant cope with that. just use meson if thats the case

Data/radare2/libr/../mk/gcc.mk:

trufae commented 2 years ago

Another reason for having this Data could be because you have overriden the LIBR env var or so? do you have any special environment variables set? export| grep Data may give you a hint

robertoll commented 2 years ago

Ok, it seems it was something to do with the directory, one of the folders had a space on it. Git cloned to root and installed without issue, thanks a lot for the help trufae.