From 88daaa079e14f674b10be117ce0fd6925d45cc09 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 29 Oct 2002 11:25:10 +0000 Subject: Remove my horrible SH hack infavor of this fix for initfini.awk from Stefan Allius , which does a better job. --- extra/scripts/initfini.awk | 17 ++++++++++++++++- libc/sysdeps/linux/common/initfini.c | 10 ---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/extra/scripts/initfini.awk b/extra/scripts/initfini.awk index 1924da9a5..c70fb8cd4 100755 --- a/extra/scripts/initfini.awk +++ b/extra/scripts/initfini.awk @@ -12,18 +12,29 @@ BEGIN \ system("/bin/rm -f crt[in].S"); omitcrti=0; omitcrtn=0; + glb_idx = 0; while(getline < "initfini.s") { if(/\.endp/) {endp=1} if(/\.end/) {end=1} if(/\.align/) {alignval=$2} +# here comes some special stuff for the SuperH targets +# Search for all labels + if(/_GLOBAL_OFFSET_TABLE_/) { + sub (":","",last); + glb_label[glb_idx] = last; + glb_idx += 1; + glb = $0; + } + last = $1; } close("initfini.s"); } +/^_init:/{omitcrtn=1;if (glb_idx>0) print glb_label[0] ":" glb >> "crti.S";} +/^_fini:/{omitcrtn=1;if (glb_idx>1) print glb_label[1] ":" glb >> "crti.S";} /HEADER_ENDS/{omitcrti=1;omitcrtn=1;getline} /PROLOG_BEGINS/{omitcrti=0;omitcrtn=0;getline} /i_am_not_a_leaf/{getline} -/_init:/||/_fini:/{omitcrtn=1} /PROLOG_PAUSES/{omitcrti=1;getline} /PROLOG_UNPAUSES/{omitcrti=0;getline} /PROLOG_ENDS/{omitcrti=1;getline} @@ -67,6 +78,10 @@ BEGIN \ { gsub("ALIGN","",$0) } } +# substitude all label references of the _GLOBAL_OFFSET_TABLE_ +# .L10 ==> .L10b etc. +glb_idx>0 { gsub (glb_label[0],sprintf("%sb",glb_label[0]),$0)} +glb_idx>1 { gsub (glb_label[1],sprintf("%sb",glb_label[1]),$0)} omitcrti==0 {print >> "crti.S"} omitcrtn==0 {print >> "crtn.S"} diff --git a/libc/sysdeps/linux/common/initfini.c b/libc/sysdeps/linux/common/initfini.c index 927ed1db3..4a6ebee75 100644 --- a/libc/sysdeps/linux/common/initfini.c +++ b/libc/sysdeps/linux/common/initfini.c @@ -109,11 +109,6 @@ void _init (void) asm ("ALIGN"); asm("END_INIT"); -#if defined(__sh__) - /* This is a horrible hack, but seems to be necessary to - * make this work for the Hitachi SH processors */ - asm ("\n.L5:\n\t.long _GLOBAL_OFFSET_TABLE_\n"); -#endif /* Now the epilog. */ asm ("\n/*@_init_PROLOG_ENDS*/"); asm ("\n/*@_init_EPILOG_BEGINS*/"); @@ -134,11 +129,6 @@ void _fini (void) /* End of the _fini prolog. */ asm ("ALIGN"); asm ("END_FINI"); -#if defined(__sh__) - /* This is a horrible hack, but seems to be necessary to - * make this work for the Hitachi SH processors */ - asm ("\n.L10:\n\t.long _GLOBAL_OFFSET_TABLE_\n"); -#endif asm ("\n/*@_fini_PROLOG_ENDS*/"); { -- cgit v1.2.3