Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol "Stat@FBSD_1.5" #57

Closed
SMIncBrett opened this issue Oct 18, 2018 · 3 comments
Closed

Undefined symbol "Stat@FBSD_1.5" #57

SMIncBrett opened this issue Oct 18, 2018 · 3 comments

Comments

@SMIncBrett
Copy link

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!

@catb0t
Copy link

catb0t commented Oct 18, 2018

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)

@intika
Copy link
Contributor

intika commented Nov 12, 2018

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

@SMIncBrett
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants