Make the iOS ARM code position-independent

This commit is contained in:
Tor Lillqvist
2012-03-05 01:24:47 +02:00
parent 8574b1f5b5
commit cc9b1e4e41
4 changed files with 23 additions and 33 deletions

View File

@@ -368,7 +368,11 @@ extern "C" void cpp_vtable_call(
extern "C" {
extern int nFunIndexes, nVtableOffsets;
extern unsigned char **codeSnippets;
#ifdef __arm
extern int codeSnippets[];
#else
extern unsigned char **codeSnippets;
#endif
}
unsigned char * codeSnippet(
@@ -389,7 +393,7 @@ unsigned char * codeSnippet(
return NULL;
#ifdef __arm
return codeSnippets[functionIndex*nVtableOffsets*2 + vtableOffset*2 + bHasHiddenParam];
return ((unsigned char *) &codeSnippets) + codeSnippets[functionIndex*nVtableOffsets*2 + vtableOffset*2 + bHasHiddenParam];
#else
enum { General, Void, Hyper, Float, Double, Class } exec;
int flag = 0;

View File

@@ -33,10 +33,9 @@ sub gen_arm ($$)
my ($funIndex, $vtableOffset) = @_;
printf ("codeSnippet%08x%d:\n", $funIndex, $vtableOffset);
printf ("\tmov ip, pc\n");
printf ("\tldr pc, [pc, #4]\n");
printf ("\tb _privateSnippetExecutor\n");
printf ("\t.long %#08x\n", $funIndex);
printf ("\t.long %d\n", $vtableOffset);
printf ("\t.long _privateSnippetExecutor\n");
}
sub gen_x86 ($$$)
@@ -48,8 +47,6 @@ sub gen_x86 ($$$)
printf ("\tjmp _privateSnippetExecutor%s\n", $executor);
}
printf ("\t.text\n");
printf ("#ifdef __arm\n");
printf ("\t.align 4\n");
@@ -94,8 +91,8 @@ foreach my $funIndex (0 .. $nFunIndexes-1)
foreach my $vtableOffset (0 .. $nVtableOffsets-1)
{
printf ("#ifdef __arm\n");
printf ("\t.long codeSnippet%08x%d\n", $funIndex, $vtableOffset);
printf ("\t.long codeSnippet%08x%d\n", $funIndex|0x80000000, $vtableOffset);
printf ("\t.long codeSnippet%08x%d - _codeSnippets\n", $funIndex, $vtableOffset);
printf ("\t.long codeSnippet%08x%d - _codeSnippets\n", $funIndex|0x80000000, $vtableOffset);
printf ("#else\n");
foreach my $executor ('General', 'Void', 'Hyper', 'Float', 'Double', 'Class')
{

View File

@@ -24,6 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "codesnippets.S"
#ifdef __arm
@ ARM support code for LibreOffice C++/UNO bridging
@
@@ -35,7 +38,6 @@
.file "helper.S"
.text
.align 4
.globl _privateSnippetExecutor
_privateSnippetExecutor:
stmfd sp!, {r0-r3} @ follow other parameters on stack
@@ -53,7 +55,6 @@ _privateSnippetExecutor:
.text
.align 1, 0x90
.globl _privateSnippetExecutorGeneral
_privateSnippetExecutorGeneral:
LFBg:
movl %esp,%ecx
@@ -74,7 +75,6 @@ LFEg:
.long .-_privateSnippetExecutorGeneral
.align 1, 0x90
.globl _privateSnippetExecutorVoid
_privateSnippetExecutorVoid:
LFBv:
movl %esp,%ecx
@@ -94,7 +94,6 @@ LFEv:
.long .-_privateSnippetExecutorVoid
.align 1, 0x90
.globl _privateSnippetExecutorHyper
_privateSnippetExecutorHyper:
LFBh:
movl %esp,%ecx
@@ -116,7 +115,6 @@ LFEh:
.long .-_privateSnippetExecutorHyper
.align 1, 0x90
.globl _privateSnippetExecutorFloat
_privateSnippetExecutorFloat:
LFBf:
movl %esp,%ecx
@@ -137,7 +135,6 @@ LFEf:
.long .-_privateSnippetExecutorFloat
.align 1, 0x90
.globl _privateSnippetExecutorDouble
_privateSnippetExecutorDouble:
LFBd:
movl %esp,%ecx
@@ -158,7 +155,6 @@ LFEd:
.long .-_privateSnippetExecutorDouble
.align 1, 0x90
.globl _privateSnippetExecutorClass
_privateSnippetExecutorClass:
LFBc:
movl %esp,%ecx
@@ -201,7 +197,6 @@ LSCIE1:
.byte 1
.align 2
LECIE1:
.globl _privateSnippetExecutorGeneral.eh
_privateSnippetExecutorGeneral.eh:
LSFDEg:
.set L$set$g1,LEFDEg-LASFDEg
@@ -224,7 +219,6 @@ LASFDEg:
.byte 4
.align 2
LEFDEg:
.globl _privateSnippetExecutorVoid.eh
_privateSnippetExecutorVoid.eh:
LSFDEv:
.set L$set$v1,LEFDEv-LASFDEv
@@ -247,7 +241,6 @@ LASFDEv:
.byte 4
.align 2
LEFDEv:
.globl _privateSnippetExecutorHyper.eh
_privateSnippetExecutorHyper.eh:
LSFDEh:
.set L$set$h1,LEFDEh-LASFDEh
@@ -270,7 +263,6 @@ LASFDEh:
.byte 4
.align 2
LEFDEh:
.globl _privateSnippetExecutorFloat.eh
_privateSnippetExecutorFloat.eh:
LSFDEf:
.set L$set$f1,LEFDEf-LASFDEf
@@ -293,7 +285,6 @@ LASFDEf:
.byte 4
.align 2
LEFDEf:
.globl _privateSnippetExecutorDouble.eh
_privateSnippetExecutorDouble.eh:
LSFDEd:
.set L$set$d1,LEFDEd-LASFDEd
@@ -316,7 +307,6 @@ LASFDEd:
.byte 4
.align 2
LEFDEd:
.globl _privateSnippetExecutorClass.eh
_privateSnippetExecutorClass.eh:
LSFDEc:
.set L$set$c1,LEFDEc-LASFDEc

View File

@@ -25,7 +25,7 @@
#
#*************************************************************************
PRJ=..$/..$/..
PRJ=../../..
PRJNAME=bridges
TARGET=gcc3_uno
@@ -43,20 +43,19 @@ ENABLE_EXCEPTIONS=TRUE
CFLAGSNOOPT=-O0
SLOFILES= \
$(SLO)$/except.obj \
$(SLO)$/cpp2uno.obj \
$(SLO)$/uno2cpp.obj \
$(SLO)$/codesnippets.obj \
$(SLO)$/helper.obj
$(SLO)/except.obj \
$(SLO)/cpp2uno.obj \
$(SLO)/uno2cpp.obj \
$(SLO)/helper.obj
SHL1TARGET= $(TARGET)
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
SHL1DEF=$(MISC)/$(SHL1TARGET).def
SHL1IMPLIB=i$(TARGET)
SHL1VERSIONMAP=..$/..$/bridge_exports.map
SHL1VERSIONMAP=../../bridge_exports.map
SHL1OBJS = $(SLOFILES)
SHL1LIBS = $(SLB)$/cpp_uno_shared.lib
SHL1LIBS = $(SLB)/cpp_uno_shared.lib
SHL1RPATH = URELIB
SHL1STDLIBS= \
@@ -68,10 +67,10 @@ SHL1STDLIBS= \
.INCLUDE : target.mk
$(SLO)$/%.obj: %.S
$(CC) -c -o $(SLO)$/$(@:b).o $<
$(SLO)/helper.obj: helper.S $(MISC)/codesnippets.S generate-snippets.pl
$(CC) -c -I $(MISC) -o $(SLO)/helper.o helper.S
touch $@
codesnippets.S: generate-snippets.pl
$(MISC)/codesnippets.S: generate-snippets.pl
$(PERL) generate-snippets.pl >$@