mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-07 15:20:18 +00:00
Merge pull request #307 from mkilgore/fix-symbol-dynamic
Fix DECLARE LIBRARY against stripped .so file
This commit is contained in:
commit
0dcce35923
5 changed files with 43 additions and 12 deletions
|
@ -12582,8 +12582,11 @@ END IF
|
|||
'Clear nm output from previous runs
|
||||
FOR x = 1 TO ResolveStaticFunctions
|
||||
IF LEN(ResolveStaticFunction_File(x)) THEN
|
||||
s$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x))
|
||||
IF _FILEEXISTS(s$) THEN KILL s$
|
||||
s$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 0)
|
||||
IF _FILEEXISTS(s$) THEN KILL s$: ClearBuffers s$
|
||||
|
||||
s$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 1)
|
||||
IF _FILEEXISTS(s$) THEN KILL s$: ClearBuffers s$
|
||||
END IF
|
||||
NEXT x
|
||||
|
||||
|
@ -12602,7 +12605,8 @@ IF os$ = "WIN" THEN
|
|||
|
||||
'resolve static function definitions and add to global.txt
|
||||
FOR x = 1 TO ResolveStaticFunctions
|
||||
nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x))
|
||||
nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 0)
|
||||
nm_output_file_dynamic$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 1)
|
||||
IF LEN(ResolveStaticFunction_File(x)) THEN
|
||||
|
||||
n = 0
|
||||
|
@ -12659,8 +12663,8 @@ IF os$ = "WIN" THEN
|
|||
END IF
|
||||
|
||||
IF n = 0 THEN 'a C++ dynamic object library?
|
||||
IF NOT _FILEEXISTS(nm_output_file$) THEN
|
||||
SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file$)
|
||||
IF NOT _FILEEXISTS(nm_output_file_dynamic$) THEN
|
||||
SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file_dynamic$)
|
||||
END IF
|
||||
s$ = " " + ResolveStaticFunction_Name(x) + "("
|
||||
fh = OpenBuffer%("I", nm_output_file$)
|
||||
|
@ -12687,7 +12691,7 @@ IF os$ = "WIN" THEN
|
|||
|
||||
IF n = 0 THEN 'a C dynamic object library?
|
||||
s$ = " " + ResolveStaticFunction_Name(x)
|
||||
fh = OpenBuffer%("I", nm_output_file$)
|
||||
fh = OpenBuffer%("I", nm_output_file_dynamic$)
|
||||
DO UNTIL EndOfBuf%(fh)
|
||||
a$ = ReadBufLine$(fh)
|
||||
IF LEN(a$) THEN
|
||||
|
@ -12751,7 +12755,8 @@ IF os$ = "LNX" THEN
|
|||
END IF
|
||||
|
||||
FOR x = 1 TO ResolveStaticFunctions
|
||||
nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x))
|
||||
nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 0)
|
||||
nm_output_file_dynamic$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 1)
|
||||
IF LEN(ResolveStaticFunction_File(x)) THEN
|
||||
|
||||
n = 0
|
||||
|
@ -12814,8 +12819,8 @@ IF os$ = "LNX" THEN
|
|||
|
||||
IF n = 0 THEN 'a C++ dynamic object library?
|
||||
IF MacOSX THEN GOTO macosx_libfind_failed
|
||||
IF NOT _FILEEXISTS(nm_output_file$) THEN
|
||||
SHELL _HIDE "nm " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file$) + " 2>" + AddQuotes$(tmpdir$ + "nm_error.txt")
|
||||
IF NOT _FILEEXISTS(nm_output_file_dynamic$) THEN
|
||||
SHELL _HIDE "nm " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file_dynamic$) + " 2>" + AddQuotes$(tmpdir$ + "nm_error.txt")
|
||||
END IF
|
||||
s$ = " " + ResolveStaticFunction_Name(x) + "("
|
||||
fh = OpenBuffer%("I", nm_output_file$)
|
||||
|
@ -12842,7 +12847,7 @@ IF os$ = "LNX" THEN
|
|||
|
||||
IF n = 0 THEN 'a C dynamic object library?
|
||||
s$ = " " + ResolveStaticFunction_Name(x)
|
||||
fh = OpenBuffer%("I", nm_output_file$)
|
||||
fh = OpenBuffer%("I", nm_output_file_dynamic$)
|
||||
DO UNTIL EndOfBuf%(fh)
|
||||
a$ = ReadBufLine$(fh)
|
||||
IF LEN(a$) THEN
|
||||
|
|
|
@ -27,6 +27,8 @@ FUNCTION GetMakeExecutable$ ()
|
|||
END IF
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION MakeNMOutputFilename$ (libfile AS STRING)
|
||||
MakeNMOutputFilename$ = tmpdir$ + "nm_output_" + StrReplace$(StrReplace$(libfile, pathsep$, "."), ":", ".") + ".txt"
|
||||
FUNCTION MakeNMOutputFilename$ (libfile AS STRING, dynamic As Long)
|
||||
If dynamic Then dyn$ = "_dynamic" Else dyn$ = ""
|
||||
|
||||
MakeNMOutputFilename$ = tmpdir$ + "nm_output_" + StrReplace$(StrReplace$(libfile, pathsep$, "."), ":", ".") + dyn$ + ".txt"
|
||||
END FUNCTION
|
||||
|
|
BIN
tests/compile_tests/declare_library_external/liblibstripped.so
Normal file
BIN
tests/compile_tests/declare_library_external/liblibstripped.so
Normal file
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
$CONSOLE:ONLY
|
||||
|
||||
$IF LNX THEN
|
||||
|
||||
' This file is missing the regular symbol table and only contains the dynamic symbol table
|
||||
DECLARE LIBRARY "./libstripped"
|
||||
FUNCTION add_values&(BYVAL v1 AS LONG, BYVAL v2 as LONG)
|
||||
END DECLARE
|
||||
|
||||
result = add_values&(2, 3)
|
||||
PRINT result
|
||||
|
||||
|
||||
$ELSE
|
||||
|
||||
' Windows can't use regular DECLARE LIBRARY to link against a dll, just skip this test
|
||||
'
|
||||
' Mac OS dylib files don't have a dynamic symbol table, so also nothing to test
|
||||
PRINT 5
|
||||
|
||||
$END IF
|
||||
|
||||
SYSTEM
|
|
@ -0,0 +1 @@
|
|||
5
|
Loading…
Reference in a new issue