简体   繁体   中英

xcrun Error running program with custom malloc on macOS

I am writing a custom malloc() - free() - realloc() set of functions for a school project.

I've written such functions and they appear to work, for example I can launch a simple program with my custom malloc and everithing works fine.

My malloc library is compiled as such ( gcc is symlinked to clang ):

# gcc -Wall -Wextra -Werror -shared -o libft_malloc_x86_64_Darwin.so ./src/malloc.o ./src/free.o ./src/realloc.o ./src/find.o ./src/alloc_mem.o ./src/show_alloc_mem.o ./src/utils.o -I ./include -I ./libft/include -I ./libft/libft -L./libft/ -L. -lft

Now, I tried to launch lldb with my malloc like this:

# ./run.sh lldb

with ./run.sh being:

#!/bin/sh
export DYLD_LIBRARY_PATH=.;
export DYLD_INSERT_LIBRARIES="libft_malloc.so";
export DYLD_FORCE_FLAT_NAMESPACE=1;
$@;

And I've got this error:

xcrun: error: unable to resolve xcrun_main (invalid handle passed to dlsym()).

What is this error about? I suppose this is a linker problem, but what this means exactly?

I've searched some info around, but nothing yet. Any tip is appreciated, as I will dig it.

I'm using macOS 10.12.6 and

# gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix

this error could happen when a function called from dynamic library does not exist. So, when you make export these variables, libc malloc will be replaced with yours. Do you implement all functions from this library?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM