neurobin / shc

Shell script compiler

Home Page:https://neurobin.org/projects/softwares/unix/shc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined symbol "Stat@FBSD_1.5"

SMIncBrett opened this issue · comments

I'm getting this error when moving compiled binaries to another similar system. The program in question just runs a single ping command, applies a regular expression to the output and echoes a result back to the console.

First system is a TrueOS FreeBSD install, second is a minimal FreeBSD install.

I've tried compiling for sh, csh and tcsh. The binary runs fine on the TrueOS system, just won't run on the target system.

I'm guessing there's an unmet dependency or library on the minimal system but was hoping someone could point me in the right direction on installing. Haven't had any luck with Google on figuring that out.

Thanks!

I'm not intimately familiar with shc (or FreeBSD, lol) but I assume it stats itself, its directory, or some character device like /dev/null

Missing a system call name is kind of interesting though, I guess it's likely that shc compiled a call to libc's stat wrapper for the FBSD system call and that name was resolved differently, at a different offset, in a different shared library, etc etc by the ELF interpreter on the minimal system

(that capital letter in Stat is kind of interesting, i hope that's an artifact and not a problem)

if you have a C compiler on the target system, can you compile and run a small program like this? (it works on Linux, hopefully on FreeBSD)

#include <sys/stat.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h> 
#include <stdio.h>

int main (int argc, char** argv) {
  struct stat s;
  if (stat(argv[0], &s)) { 
    perror("stat #1");
    return 1;
  }
  if (syscall(SYS_stat, argv[0], &s)) { 
    perror("stat #2");
    return 1;
  }
}

if it compiles and runs and file ./stat says dynamically linked then the problem is a version or address mismatch for the symbol and / or library that loads the stat symbol between your two systems, and you might have to force static linking when shc compiles.

(if it attempted to actually compile a call to a symbol named stat@FBSD_15 or something, then it really is a version mismatch)

Can you test with the last version with the flag 'H'
Also compile your bash without any additional flag and try again
Also with the same unprotected binary, can you run strace your-binary and report back

Yes, this was a user error on my part. Once I ran with -r this issue disappeared.