Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-14 Thread Christian Jullien
Just tested on:
jullien@gcc113:~/tinycc$ uname -a
Linux gcc113 3.13.0-92-generic #139-Ubuntu SMP Tue Jun 28 20:45:34 UTC 2016
aarch64 aarch64 aarch64 GNU/Linux

Fully working, no error at all!

Thanks
Christian

-Original Message-
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org]
On Behalf Of Michael Matz
Sent: vendredi 14 octobre 2016 17:45
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of
R_AARCH64_CALL26.

Hi,

On Tue, 11 Oct 2016, Edmund Grimley Evans wrote:

> Me:
> 
> > That's interesting. Perhaps that could be extended to AArch64 
> > instead of using the ugly work-around...
> 
> I've pushed my work-around as I'm not sure when I'll be able to 
> investigate the linker...

Just for the benefit of the list: that's fixed now.


Ciao,
Michael.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-14 Thread Edmund Grimley Evans
Michael Matz :

> > I've pushed my work-around as I'm not sure when I'll be able to
> > investigate the linker...
> 
> Just for the benefit of the list: that's fixed now.

Many thanks!

Edmund

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-14 Thread Michael Matz
Hi,

On Tue, 11 Oct 2016, Edmund Grimley Evans wrote:

> Me:
> 
> > That's interesting. Perhaps that could be extended to AArch64 instead
> > of using the ugly work-around...
> 
> I've pushed my work-around as I'm not sure when I'll be able to
> investigate the linker...

Just for the benefit of the list: that's fixed now.


Ciao,
Michael.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-11 Thread Edmund Grimley Evans
Me:

> That's interesting. Perhaps that could be extended to AArch64 instead
> of using the ugly work-around...

I've pushed my work-around as I'm not sure when I'll be able to
investigate the linker...

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-11 Thread Edmund Grimley Evans
> >This is a work-around for TCC's linker not building a PLT when TCC is
> >invoked with "-run".
> 
> Hm, are you sure?  See
> 
> 9750d0b725d65296364c08451a985c717bf1890d
> Author: Michael Matz ... 2014-04-06 00:30:22
> 
> x86_64: Create proper PLT and GOT also for -run
> 
> 01c041923474750a236da02561f0f8835445848b
> Author: Michael Matz ... 2014-04-06 01:02:42
> 
> arm: Use proper PLT/GOT for -run.

That's interesting. Perhaps that could be extended to AArch64 instead
of using the ugly work-around...

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-10 Thread grischka

Edmund Grimley Evans wrote:

This is a work-around for TCC's linker not building a PLT when TCC is
invoked with "-run".


Hm, are you sure?  See

9750d0b725d65296364c08451a985c717bf1890d
Author: Michael Matz ... 2014-04-06 00:30:22

x86_64: Create proper PLT and GOT also for -run

01c041923474750a236da02561f0f8835445848b
Author: Michael Matz ... 2014-04-06 01:02:42

arm: Use proper PLT/GOT for -run.

-- gr



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-10 Thread Christian Jullien
Ops, I read too fast yesterday on my phone and I omitted your patch
bound in mail (I thought it was already pushed).

I'm really sorry AS IT FULLY WORKS (including all possible tests).

 

Many thanks.

 

 

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org]
On Behalf Of Christian Jullien
Sent: mardi 11 octobre 2016 06:47
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of
R_AARCH64_CALL26.

 

Thank you Edmund, but it does not work (see below).

 

Btw, do you know that can ask for an account on GCC Compile Farm Project
(see: https://gcc.gnu.org/wiki/CompileFarm)

Here you can have remote access on different machines for free. Among them
you have:

 

name   port disk   CPU   Notes

gcc113  500GB  8x2.4 GHz aarch64 / 32 GB RAM / APM X-Gene Mustang
board / Ubuntu 14.04.3 LTS

gcc114  500GB  8x2.4 GHz aarch64 / 32 GB RAM / APM X-Gene Mustang
board / Ubuntu 14.04.3 LTS

gcc115  500GB  8x2.4 GHz aarch64 / 32 GB RAM / APM X-Gene Mustang
board / Ubuntu 14.04.3 LTS

gcc116  500GB  8x2.4 GHz aarch64 / 32 GB RAM / APM X-Gene Mustang
board / Ubuntu 14.04.3 LTS

 

This is where I tested:

 

jullien@gcc113:~/tinycc$ more config.h

/* Automatically generated by configure - do not modify */

#ifndef CONFIG_TCCDIR

# define CONFIG_TCCDIR "/usr/local/lib/tcc"

#endif

#define GCC_MAJOR 4

#define GCC_MINOR 8

#define TCC_VERSION "0.9.26"

jullien@gcc113:~/tinycc$ export LD_LIBRARY_PATH=/usr/local/lib/tcc

jullien@gcc113:~/tinycc$ ./configure

Binary  directory   /usr/local/bin

TinyCC directory/usr/local/lib/tcc

Library directory   /usr/local/lib

Include directory   /usr/local/include

Manual directory/usr/local/share/man

Info directory  /usr/local/share/info

Doc directory   /usr/local/share/doc

Target root prefix

Source path /home/jullien/tinycc

C compiler  gcc

Target OS   Linux

CPU aarch64

Big Endian  no

gprof enabled   no

cross compilers no

use libgcc  no

Creating config.mak and config.h

config.h is unchanged

jullien@gcc113:~/tinycc$ make

gcc -o tcc.o -c tcc.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aarch64-

linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2 -Wdeclaration-after-statement
-Wno-

deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-compare

-Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o libtcc.o -c libtcc.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aa

rch64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-statement

-Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-c

ompare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o tccpp.o -c tccpp.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aarc

h64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-statement -

Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-com

pare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o tccgen.o -c tccgen.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aa

rch64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-statement

-Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-c

ompare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o tccelf.o -c tccelf.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aa

rch64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-statement

-Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-c

ompare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o tccasm.o -c tccasm.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aa

rch64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-statement

-Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-c

ompare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o tccrun.o -c tccrun.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR="\"aa

rch64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-statement

-Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-sign-c

ompare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -I.

gcc -o arm64-gen.o -c arm64-gen.c -DCONFIG_LDDIR="\"lib\""
-DCONFIG_MULTIARCHDIR

="\"aarch64-linux-gnu\"" -DTCC_TARGET_ARM64 -Wall -g -O2
-Wdeclaration-after-sta

tement -Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign
-Wno-

sign-compare -Wno-unuse

Re: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-10 Thread Christian Jullien
rm64.o

make[1]: Leaving directory `/home/jullien/tinycc/lib'

jullien@gcc113:~/tinycc$ make test

make -C tests

make[1]: Entering directory `/home/jullien/tinycc/tests'

 hello-exe 

../tcc -B.. -I../include -I.. -I.. ../examples/ex1.c -o hello || (../tcc
-vv; ex

it 1) && ./hello

Hello World

 hello-run 

../tcc -B.. -I../include -I.. -I.. -run ../examples/ex1.c

Hello World

gcc -o libtcc_test libtcc_test.c ../libtcc.a -I.. -I.. -lm -ldl

 libtest 

./libtcc_test -B.. -I../include -I.. -I..

tcc: error: R_AARCH64_(JUMP|CALL)26 relocation failed (val=27c4e7cc,
addr=401b10

)

make[1]: *** [libtest] Error 1

 

-Original Message-

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org]
On Behalf Of Edmund Grimley Evans

Sent: lundi 10 octobre 2016 22:18

To: tinycc-devel@nongnu.org

Subject: [Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of
R_AARCH64_CALL26.

 

I'll push this in about 24 hours if nobody objects. TCC might work on the
"APM X-Gene Mustang board / Ubuntu 14.04.3 LTS" with this.

 

Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.



This is a work-around for TCC's linker not building a PLT when TCC is

invoked with "-run".

 

diff --git a/arm64-gen.c b/arm64-gen.c

index f9f9581..5f52e1f 100644

--- a/arm64-gen.c

+++ b/arm64-gen.c

@@ -592,13 +592,22 @@ ST_FUNC void store(int r, SValue *sv)

 static void arm64_gen_bl_or_b(int b)

{

+// Currently TCC's linker does not generate a PLT when TCC is invoked

+// with "-run". This means functions can be out of range if we try to

+// call them in the usual way. Until the linker is fixed, work around

+// this by using R_AARCH64_MOVW_UABS_G* relocations; see arm64_sym.

+int avoid_call26 = 1;

+

 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {

-assert(!b);

-if (vtop->r & VT_SYM)

+assert(!b && (vtop->r & VT_SYM));

+if (avoid_call26) {

+arm64_sym(30, vtop->sym, 0);

+o(0xd63f03c0); // blr x30

+}

+else {

 greloc(cur_text_section, vtop->sym, ind, R_AARCH64_CALL26);

-else

-assert(0);

-o(0x9400); // bl .

+o(0x9400); // bl .

+}

 }

 else

 o(0xd61f | (uint32_t)!b << 21 | intr(gv(RC_R30)) << 5); //
br/blr

 

___

Tinycc-devel mailing list

Tinycc-devel@nongnu.org

https://lists.nongnu.org/mailman/listinfo/tinycc-devel

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] PATCH: Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

2016-10-10 Thread Edmund Grimley Evans
I'll push this in about 24 hours if nobody objects. TCC might work on
the "APM X-Gene Mustang board / Ubuntu 14.04.3 LTS" with this.

Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

This is a work-around for TCC's linker not building a PLT when TCC is
invoked with "-run".

diff --git a/arm64-gen.c b/arm64-gen.c
index f9f9581..5f52e1f 100644
--- a/arm64-gen.c
+++ b/arm64-gen.c
@@ -592,13 +592,22 @@ ST_FUNC void store(int r, SValue *sv)
 
 static void arm64_gen_bl_or_b(int b)
 {
+// Currently TCC's linker does not generate a PLT when TCC is invoked
+// with "-run". This means functions can be out of range if we try to
+// call them in the usual way. Until the linker is fixed, work around
+// this by using R_AARCH64_MOVW_UABS_G* relocations; see arm64_sym.
+int avoid_call26 = 1;
+
 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
-assert(!b);
-if (vtop->r & VT_SYM)
+assert(!b && (vtop->r & VT_SYM));
+if (avoid_call26) {
+arm64_sym(30, vtop->sym, 0);
+o(0xd63f03c0); // blr x30
+}
+else {
 greloc(cur_text_section, vtop->sym, ind, R_AARCH64_CALL26);
-else
-assert(0);
-o(0x9400); // bl .
+o(0x9400); // bl .
+}
 }
 else
 o(0xd61f | (uint32_t)!b << 21 | intr(gv(RC_R30)) << 5); // br/blr

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel