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

dyld: warning: could not load inserted library './assets/malloc.dylib' #113

Open
Florian-A opened this issue Nov 15, 2021 · 3 comments
Open

Comments

@Florian-A
Copy link

Florian-A commented Nov 15, 2021

Hello guy.

I clone my repo in the goinfre and i started make command and ./run_test.

I have this message on ft_striteri:

dyld: warning: could not load inserted library './assets/malloc.dylib' into hardened process because no suitable image found. Did find: ./assets/malloc.dylib: code signature in (./assets/malloc.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. ./assets/malloc.dylib: stat() failed with errno=1

When i restart ./run_test this message vanish.

My ft_striteri :

#include "libft.h"

void	ft_striteri(char *s, void (*f)(unsigned int, char*))
{
	unsigned int	i;

	if (!s)
		return ;
	i = 0;
	while (s[i])
	{
		(*f)(i, &s[i]);
		i++;
	}
}

Thanks for your work !

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

Hello! Thanks for contributing to the libft unit test.

Note that this repository is not maintained by the owner anymore, instead there is a bot that will automatically merge any reviewed pull requests.
If you feel like it, here are some links that can help you submiting a change in the code base::

@Sangyao42
Copy link

Hello guy.

I clone my repo in the goinfre and i started make command and ./run_test.

I have this message on ft_striteri:

dyld: warning: could not load inserted library './assets/malloc.dylib' into hardened process because no suitable image found. Did find: ./assets/malloc.dylib: code signature in (./assets/malloc.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. ./assets/malloc.dylib: stat() failed with errno=1

When i restart ./run_test this message vanish.

My ft_striteri :

#include "libft.h"

void	ft_striteri(char *s, void (*f)(unsigned int, char*))
{
	unsigned int	i;

	if (!s)
		return ;
	i = 0;
	while (s[i])
	{
		(*f)(i, &s[i]);
		i++;
	}
}

Thanks for your work

Hello, I am working on Libft and have the same problem. Could you please tell me how to solve it? Is it some problem with my functions?

@chunkhang
Copy link

I faced this issue too. After reading a bit about arm64e in macOS, I managed to fix it.

In Makefile, look for the definition of DYLIBFLAG variable:

ifeq ($(OS),Linux)
	DYLIBFLAG = -fPIC -shared -ldl
else
	DYLIBFLAG = -dynamiclib
endif

Update DYLIBFLAG for macOS from -dynamiclib to -dynamiclib -arch arm64e:

ifeq ($(OS),Linux)
	DYLIBFLAG = -fPIC -shared -ldl
else
	DYLIBFLAG = -dynamiclib -arch arm64e
endif

The new Makefile should compile assets/malloc.c into assets/malloc.dylib correctly, which you can verify:

$ file assets/malloc.dylib
assets/malloc.dylib: Mach-O 64-bit dynamically linked shared library arm64e

If you're interested to read more about arm64e:
https://github.com/lelegard/arm-cpusysregs/blob/main/docs/arm64e-on-macos.md

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