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

fun address is the same after Multiple load In Ubuntu #143

Open
Terrency opened this issue Jun 14, 2023 · 1 comment
Open

fun address is the same after Multiple load In Ubuntu #143

Terrency opened this issue Jun 14, 2023 · 1 comment

Comments

@Terrency
Copy link

we loaded same so with different name twice, and found that normal function address is the same in Linux environment

        MyLibrary libc = LibraryLoader.create(MyLibrary.class).load("testjnr");
        MyLibrary1 libc1 = LibraryLoader.create(MyLibrary1.class).load("testjnr1");
static int func1()
{
	return 0;
}

int func2()
{
	return 1;
}

we print address of func1 in Windows and Ubuntu, it is different address in memory
but address of func2 is the same in Ubuntu, it is different in Windows.
it seem that normal function could be override by loading in Ubuntu and CentOS.
could some one help to fix this bug.
we try the sample with JNI, JNI is OK.

@Terrency Terrency changed the title fun address is the same after Multiple load so fun address is the same after Multiple load In Ubuntu Jun 14, 2023
@Terrency
Copy link
Author

we fixed it by change jnr-jffi project.
NativeLibrary -> openLibrary with getCachedInstance

before
lib = com.kenai.jffi.Library.getCachedInstance(path, com.kenai.jffi.Library.LAZY | com.kenai.jffi.Library.GLOBAL);
after
lib = com.kenai.jffi.Library.getCachedInstance(path, com.kenai.jffi.Library.LAZY | com.kenai.jffi.Library.LOCAL);

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

1 participant