Skip to content

Commit

Permalink
Fix a possible NPE in Darwin build + rebuild some binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ochafik committed Dec 25, 2016
1 parent f221b36 commit 12176ca
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 17 deletions.
6 changes: 5 additions & 1 deletion BuildNative
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function build_libraries() {
local DYNCALL_CONFIGURE_ARGS=""
if [[ "$ARCH" != "$NATIVE_ARCH" ]]; then
DYNCALL_CONFIGURE_ARGS="--target-$ARCH"
fi
fi
sh ./configure $DYNCALL_CONFIGURE_ARGS
$MAKE_CMD $@ || failed "Failed building dyncall"

Expand Down Expand Up @@ -171,5 +171,9 @@ if [[ $OS =~ sunos ]]; then
ARCH=x86 build_libraries $@
ARCH=x64 build_libraries $@
else
if [[ $OS =~ darwin ]]; then
export AS=llvm-as
export CC=llvm-gcc
fi
build_libraries $@
fi
Binary file modified src/main/android-libs/armeabi-v7a/libbridj.so
Binary file not shown.
Binary file modified src/main/android-libs/armeabi/libbridj.so
Binary file not shown.
Binary file modified src/main/android-libs/x86/libbridj.so
Binary file not shown.
5 changes: 4 additions & 1 deletion src/main/cpp/bridj/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CPPFLAGS += -mtune=generic
endif

ifeq ($(OS), darwin)
CPPFLAGS += -no-integrated-as
# CPPFLAGS += -no-integrated-as
CPPFLAGS += -D_DARWIN_C_SOURCE
CPPFLAGS += -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/
CPPFLAGS += -mmacosx-version-min=10.4
Expand All @@ -49,6 +49,9 @@ endif
CPPFLAGS += -U_FORTIFY_SOURCE
#CPPFLAGS += -Werror
CPPFLAGS += -std=c99
ifeq ($(OS), darwin)
CPPFLAGS += -stdlib=libstdc++
endif

ifeq ($(ARCH), x64)
UNITS += GLIBCCompatibilityWraps
Expand Down
32 changes: 17 additions & 15 deletions src/main/cpp/bridj/dyncall.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
--- a/dynload/dynload_syms_mach-o.c Thu Mar 19 22:24:28 2015 +0100
+++ b/dynload/dynload_syms_mach-o.c Sat Mar 21 11:08:07 2015 +0000
diff -r bbefb8b8e74c dynload/dynload_syms_mach-o.c
--- a/dynload/dynload_syms_mach-o.c Thu Nov 24 23:47:31 2016 +0000
+++ b/dynload/dynload_syms_mach-o.c Sun Dec 25 20:36:56 2016 +0100
@@ -29,6 +29,7 @@
dynamic symbol resolver for Mach-O

Expand Down Expand Up @@ -167,7 +167,7 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c

DLSyms* dlSymsInit(const char* libPath)
{
@@ -71,27 +201,59 @@
@@ -71,27 +201,61 @@
for (iImage = 0, nImages = _dyld_image_count(); iImage < nImages; iImage++)
{
const char* name = _dyld_get_image_name(iImage);
Expand Down Expand Up @@ -197,6 +197,8 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
{
- if (cmd->cmd == LC_SYMTAB)
- {
+ if (!cmd) continue;
+
+ if (cmd->cmd == LC_DYLD_INFO_ONLY || cmd->cmd == LC_DYLD_INFO) {
+ const struct dyld_info_command* dcmd = (const struct dyld_info_command*)cmd;
+ const unsigned char* trie = (pBase + dcmd->export_off);
Expand Down Expand Up @@ -233,15 +235,15 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
pSyms->symbolCount = scmd->nsyms;
pSyms->pStringTable = pBase + scmd->stroff;
pSyms->pSymbolTable = (struct NLIST_TYPE*)(pBase + scmd->symoff);
@@ -101,7 +263,6 @@
@@ -101,7 +265,6 @@
cmd = (const struct load_command*)(((char*)cmd) + cmd->cmdsize);
}
}
- break;
}
}
return NULL;
@@ -113,6 +274,18 @@
@@ -113,6 +276,18 @@
if (!pSyms)
return;

Expand All @@ -260,7 +262,7 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
dlFreeMem(pSyms);
}

@@ -133,6 +306,11 @@
@@ -133,6 +308,11 @@
if (nl->n_un.n_strx <= 1)
return NULL; // would be empty string anyway

Expand All @@ -272,7 +274,7 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
//TODO skip more symbols based on nl->n_desc and nl->n_type ?
return nl;
}
@@ -140,6 +318,12 @@
@@ -140,6 +320,12 @@

const char* dlSymsName(DLSyms* pSyms, int index)
{
Expand All @@ -285,7 +287,7 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
const struct NLIST_TYPE* nl = get_nlist(pSyms, index);
if (!nl)
return NULL;
@@ -150,6 +334,12 @@
@@ -150,6 +336,12 @@

void* dlSymsValue(DLSyms* pSyms, int index)
{
Expand All @@ -298,9 +300,9 @@ diff -r 3e629dc19168 dynload/dynload_syms_mach-o.c
const struct NLIST_TYPE* nl = get_nlist(pSyms, index);
if (!nl)
return NULL;
diff -r 3e629dc19168 dynload/dynload_unix.c
--- a/dynload/dynload_unix.c Thu Mar 19 22:24:28 2015 +0100
+++ b/dynload/dynload_unix.c Sat Mar 21 11:08:07 2015 +0000
diff -r bbefb8b8e74c dynload/dynload_unix.c
--- a/dynload/dynload_unix.c Thu Nov 24 23:47:31 2016 +0000
+++ b/dynload/dynload_unix.c Sun Dec 25 20:36:56 2016 +0100
@@ -41,7 +41,7 @@

DLLib* dlLoadLibrary(const char* libPath)
Expand All @@ -310,9 +312,9 @@ diff -r 3e629dc19168 dynload/dynload_unix.c
}


diff -r 3e629dc19168 dynload/dynload_windows.c
--- a/dynload/dynload_windows.c Thu Mar 19 22:24:28 2015 +0100
+++ b/dynload/dynload_windows.c Sat Mar 21 11:08:07 2015 +0000
diff -r bbefb8b8e74c dynload/dynload_windows.c
--- a/dynload/dynload_windows.c Thu Nov 24 23:47:31 2016 +0000
+++ b/dynload/dynload_windows.c Sun Dec 25 20:36:56 2016 +0100
@@ -41,7 +41,9 @@
DLLib* dlLoadLibrary(const char* libPath)
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified src/test/resources/org/bridj/lib/darwin_universal/libtest.dylib
Binary file not shown.

0 comments on commit 12176ca

Please sign in to comment.