diff mbox

[U-Boot] PowerPC: Move -fPIC flag to common place

Message ID OF8B32E14F.150B51B9-ONC1257878.0044927E-C1257878.00452684@transmode.se
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Commit Message

Joakim Tjernlund April 20, 2011, 12:35 p.m. UTC
Wolfgang Denk <wd@denx.de> wrote on 2011/04/20 00:41:01:
>
> Dear Joakim Tjernlund,
>
> In message <OFBC9C03BC.436C27C7-ONC1257877.00797190-C1257877.007A0FD7@transmode.se> you wrote:
> >
> > > Yes, but you yorself pointed out that commit 337f5f5 missed a large
> > > number of boards, leaving the tree in a inconsistent state. Should we
> > > not revert that one as well?
> >
> > It is not too bad, just not complete yet. Reverting all just makes
> > it harder to get it all done.
> > I still don't get why it broke really.
> > hmm, did you by any chance include my patches to gcc too?
> > if so I you should only have to fixup arch/powerpc/config.mk:
> > - PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
> > - PLATFORM_RELFLAGS += $(call cc-option,-msingle-pic-base,)
> > + PLATFORM_RELFLAGS += -fPIC -mrelocatable -ffunction-sections -fdata-sections
>
> Can you please have a look at this yourslef?  You understand much
> better than me which of your patches are doing what, and how they
> might interact.
>
> I don't have the time to dig into this any deeper.  If we cannot find
> a quick solution, I suggest to back out all this stuff and redo once
> the problems have been sorted out.  Sorry for applying the stuff to
> mainline without more thorough testing, I should have noticed these
> issues earlier and never checked in all that stuff.

OK, I managed to script the change, patch last in mail.

However CROSS_COMPILE=powerpc-softfloat-linux-gnu- ./MAKEALL  TQM862L TQM855L TQM860L
does not build for me, same problem as you got.
Even if I manually back out the 2 patches affecting 8xx it wont build.
I think these boards have some other problem really, like u-boot is too big for them.

Most other 8xx boards build fine, those that don't have some other problem.

From ce7970dd177a798c5ab7e093adadfc57a97ce0e7 Mon Sep 17 00:00:00 2001
From: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Date: Wed, 20 Apr 2011 14:22:59 +0200
Subject: [PATCH] powerpc, 8xx: Fixup all 8xx u-boot.lds scripts

8xx was left behind when fixing up powerpc linking
scripts to support -fpic.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 board/LEOX/elpt860/u-boot.lds        |    5 +++--
 board/RPXClassic/u-boot.lds          |    5 +++--
 board/RPXlite/u-boot.lds             |    5 +++--
 board/RPXlite_dw/u-boot.lds          |    5 +++--
 board/RRvision/u-boot.lds            |    5 +++--
 board/adder/u-boot.lds               |    5 +++--
 board/amirix/ap1000/u-boot.lds       |    5 +++--
 board/c2mon/u-boot.lds               |    5 +++--
 board/cogent/u-boot.lds              |    5 +++--
 board/dave/PPChameleonEVB/u-boot.lds |    3 ++-
 board/eltec/mhpc/u-boot.lds          |    5 +++--
 board/emk/top860/u-boot.lds          |    5 +++--
 board/ep88x/u-boot.lds               |    3 ++-
 board/esd/dasa_sim/u-boot.lds        |    5 +++--
 board/esteem192e/u-boot.lds          |    5 +++--
 board/etx094/u-boot.lds              |    5 +++--
 board/evb64260/u-boot.lds            |    5 +++--
 board/fads/u-boot.lds                |    5 +++--
 board/flagadm/u-boot.lds             |    5 +++--
 board/gen860t/u-boot.lds             |    5 +++--
 board/genietv/u-boot.lds             |    5 +++--
 board/hermes/u-boot.lds              |    5 +++--
 board/hymod/u-boot.lds               |    2 +-
 board/icu862/u-boot.lds              |    5 +++--
 board/ip860/u-boot.lds               |    5 +++--
 board/ivm/u-boot.lds                 |    5 +++--
 board/kup/kup4k/u-boot.lds           |    5 +++--
 board/kup/kup4x/u-boot.lds           |    5 +++--
 board/lantec/u-boot.lds              |    5 +++--
 board/lwmon/u-boot.lds               |    5 +++--
 board/manroland/uc100/u-boot.lds     |    5 +++--
 board/matrix_vision/mvsmr/u-boot.lds |    3 ++-
 board/mbx8xx/u-boot.lds              |    5 +++--
 board/ml2/u-boot.lds                 |    5 +++--
 board/mousse/u-boot.lds              |    5 +++--
 board/mvblue/u-boot.lds              |    5 +++--
 board/netphone/u-boot.lds            |    5 +++--
 board/netta/u-boot.lds               |    5 +++--
 board/netta2/u-boot.lds              |    5 +++--
 board/netvia/u-boot.lds              |    5 +++--
 board/nx823/u-boot.lds               |    5 +++--
 board/quantum/u-boot.lds             |    5 +++--
 board/r360mpi/u-boot.lds             |    5 +++--
 board/rbc823/u-boot.lds              |    5 +++--
 board/rmu/u-boot.lds                 |    5 +++--
 board/rsdproto/u-boot.lds            |    2 +-
 board/sandpoint/u-boot.lds           |    5 +++--
 board/sc3/u-boot.lds                 |    5 +++--
 board/siemens/IAD210/u-boot.lds      |    5 +++--
 board/sixnet/u-boot.lds              |    5 +++--
 board/snmc/qs850/u-boot.lds          |    5 +++--
 board/snmc/qs860t/u-boot.lds         |    5 +++--
 board/spc1920/u-boot.lds             |    5 +++--
 board/spd8xx/u-boot.lds              |    5 +++--
 board/stx/stxxtc/u-boot.lds          |    5 +++--
 board/svm_sc8xx/u-boot.lds           |    5 +++--
 board/tqc/tqm8xx/u-boot.lds          |    5 +++--
 board/v37/u-boot.lds                 |    5 +++--
 board/westel/amx860/u-boot.lds       |    5 +++--
 59 files changed, 170 insertions(+), 113 deletions(-)

--
1.7.3.4

Comments

Wolfgang Denk April 20, 2011, 8:13 p.m. UTC | #1
Dear Joakim Tjernlund,

In message <OF8B32E14F.150B51B9-ONC1257878.0044927E-C1257878.00452684@transmode.se> you wrote:
>
> OK, I managed to script the change, patch last in mail.

Thanks.

> However CROSS_COMPILE=powerpc-softfloat-linux-gnu- ./MAKEALL  TQM862L TQM855L TQM860L
> does not build for me, same problem as you got.
> Even if I manually back out the 2 patches affecting 8xx it wont build.
> I think these boards have some other problem really, like u-boot is too big for them.
> 
> Most other 8xx boards build fine, those that don't have some other problem.

I bisected the build issue, and it pointed at your patch.


> From ce7970dd177a798c5ab7e093adadfc57a97ce0e7 Mon Sep 17 00:00:00 2001
> From: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> Date: Wed, 20 Apr 2011 14:22:59 +0200
> Subject: [PATCH] powerpc, 8xx: Fixup all 8xx u-boot.lds scripts
> 
> 8xx was left behind when fixing up powerpc linking
> scripts to support -fpic.
> 
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>  board/LEOX/elpt860/u-boot.lds        |    5 +++--
>  board/RPXClassic/u-boot.lds          |    5 +++--
>  board/RPXlite/u-boot.lds             |    5 +++--
>  board/RPXlite_dw/u-boot.lds          |    5 +++--
>  board/RRvision/u-boot.lds            |    5 +++--
>  board/adder/u-boot.lds               |    5 +++--
>  board/amirix/ap1000/u-boot.lds       |    5 +++--
>  board/c2mon/u-boot.lds               |    5 +++--
>  board/cogent/u-boot.lds              |    5 +++--
>  board/dave/PPChameleonEVB/u-boot.lds |    3 ++-
>  board/eltec/mhpc/u-boot.lds          |    5 +++--
>  board/emk/top860/u-boot.lds          |    5 +++--
>  board/ep88x/u-boot.lds               |    3 ++-
>  board/esd/dasa_sim/u-boot.lds        |    5 +++--
>  board/esteem192e/u-boot.lds          |    5 +++--
>  board/etx094/u-boot.lds              |    5 +++--
>  board/evb64260/u-boot.lds            |    5 +++--
>  board/fads/u-boot.lds                |    5 +++--
>  board/flagadm/u-boot.lds             |    5 +++--
>  board/gen860t/u-boot.lds             |    5 +++--
>  board/genietv/u-boot.lds             |    5 +++--
>  board/hermes/u-boot.lds              |    5 +++--
>  board/hymod/u-boot.lds               |    2 +-
>  board/icu862/u-boot.lds              |    5 +++--
>  board/ip860/u-boot.lds               |    5 +++--
>  board/ivm/u-boot.lds                 |    5 +++--
>  board/kup/kup4k/u-boot.lds           |    5 +++--
>  board/kup/kup4x/u-boot.lds           |    5 +++--
>  board/lantec/u-boot.lds              |    5 +++--
>  board/lwmon/u-boot.lds               |    5 +++--
>  board/manroland/uc100/u-boot.lds     |    5 +++--
>  board/matrix_vision/mvsmr/u-boot.lds |    3 ++-
>  board/mbx8xx/u-boot.lds              |    5 +++--
>  board/ml2/u-boot.lds                 |    5 +++--
>  board/mousse/u-boot.lds              |    5 +++--
>  board/mvblue/u-boot.lds              |    5 +++--
>  board/netphone/u-boot.lds            |    5 +++--
>  board/netta/u-boot.lds               |    5 +++--
>  board/netta2/u-boot.lds              |    5 +++--
>  board/netvia/u-boot.lds              |    5 +++--
>  board/nx823/u-boot.lds               |    5 +++--
>  board/quantum/u-boot.lds             |    5 +++--
>  board/r360mpi/u-boot.lds             |    5 +++--
>  board/rbc823/u-boot.lds              |    5 +++--
>  board/rmu/u-boot.lds                 |    5 +++--
>  board/rsdproto/u-boot.lds            |    2 +-
>  board/sandpoint/u-boot.lds           |    5 +++--
>  board/sc3/u-boot.lds                 |    5 +++--
>  board/siemens/IAD210/u-boot.lds      |    5 +++--
>  board/sixnet/u-boot.lds              |    5 +++--
>  board/snmc/qs850/u-boot.lds          |    5 +++--
>  board/snmc/qs860t/u-boot.lds         |    5 +++--
>  board/spc1920/u-boot.lds             |    5 +++--
>  board/spd8xx/u-boot.lds              |    5 +++--
>  board/stx/stxxtc/u-boot.lds          |    5 +++--
>  board/svm_sc8xx/u-boot.lds           |    5 +++--
>  board/tqc/tqm8xx/u-boot.lds          |    5 +++--
>  board/v37/u-boot.lds                 |    5 +++--
>  board/westel/amx860/u-boot.lds       |    5 +++--
>  59 files changed, 170 insertions(+), 113 deletions(-)

Thanks, applied.

Problem is still present.

Bisected again:

39768f7715ed637ef02f49fc7de664cc1aaf14b3 is the first bad commit
commit 39768f7715ed637ef02f49fc7de664cc1aaf14b3
Author: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Date:   Mon Dec 6 18:35:37 2010 +0100

    PowerPC: Add support for -msingle-pic-base


I revert this commit now.  Result:

-> ./MAKEALL TQM860L
Configuring for TQM860L board...
u-boot.lds:75 cannot move location counter backwards (from 40008024 to 40008000)
make: *** [u-boot] Error 1
ppc_8xx-size: './u-boot': No such file

--------------------- SUMMARY ----------------------------
Boards compiled: 1
Boards with warnings or errors: 1 ( TQM860L )
----------------------------------------------------------
-> git revert 39768f7715ed637ef02f49fc7de664cc1aaf14b3
[master 8c4734e] Revert "PowerPC: Add support for -msingle-pic-base"
 13 files changed, 12 insertions(+), 127 deletions(-)
-> ./MAKEALL TQM860L
Configuring for TQM860L board...
   text    data     bss     dec     hex filename
 258127   14768   27228  300123   4945b ./u-boot

--------------------- SUMMARY ----------------------------
Boards compiled: 1
----------------------------------------------------------


Please feel free to resubmit when this commit does not cause problems
any more.

Best regards,

Wolfgang Denk
Joakim Tjernlund April 22, 2011, 8:13 a.m. UTC | #2
Wolfgang Denk <wd@denx.de> wrote on 2011/04/20 22:13:35:
>
> Dear Joakim Tjernlund,
>
> In message <OF8B32E14F.150B51B9-ONC1257878.0044927E-C1257878.00452684@transmode.se> you wrote:
> >
> > OK, I managed to script the change, patch last in mail.
>
> Thanks.
>
> > However CROSS_COMPILE=powerpc-softfloat-linux-gnu- ./MAKEALL  TQM862L TQM855L TQM860L
> > does not build for me, same problem as you got.
> > Even if I manually back out the 2 patches affecting 8xx it wont build.
> > I think these boards have some other problem really, like u-boot is too big for them.
> >
> > Most other 8xx boards build fine, those that don't have some other problem.
>
> I bisected the build issue, and it pointed at your patch.

hmm, this is strange. The only way I managed to build these boards
was with my patches applied and with a gcc that understands -msingle-pic-base et. all

Backing out all 3 patches did not help. Not with gcc 3.4.6, 4.4.5 or 4.5.2
so I am really lost why your gcc(of which I know nothing) works.

I suspect it is just plain luck that it works for you. If you add
-fno-jump-tables to your gcc, does it break?

 Jocke
Joakim Tjernlund April 24, 2011, 8:29 a.m. UTC | #3
With these patches 8xx willbuild again for me
with a number of gcc's even with "Add support for -msingle-pic-base"
I hope WD's gcc will also work.

Joakim Tjernlund (3):
  powerpc, 8xx: Fix fallout from "Fixup all 8xx u-boot.lds scripts"
  Fix a few gcc warnings.
  powerpc, 8xx: adapt a few linker scripts so it will build.

 board/LEOX/elpt860/u-boot.lds        |    2 +-
 board/etx094/u-boot.lds              |    2 +-
 board/matrix_vision/mvsmr/u-boot.lds |    2 +-
 board/netta/codec.c                  |    6 +++---
 board/rsdproto/u-boot.lds            |    7 ++++---
 board/siemens/IAD210/atm.c           |    4 ++--
 board/svm_sc8xx/u-boot.lds           |    2 +-
 board/tqc/tqm8xx/u-boot.lds          |    2 ++
 examples/standalone/timer.c          |    4 ++--
 9 files changed, 17 insertions(+), 14 deletions(-)
Wolfgang Denk April 24, 2011, 2:30 p.m. UTC | #4
Dear Joakim Tjernlund,

In message <1303633774-22961-1-git-send-email-Joakim.Tjernlund@transmode.se> you wrote:
> With these patches 8xx willbuild again for me
> with a number of gcc's even with "Add support for -msingle-pic-base"
> I hope WD's gcc will also work.
> 
> Joakim Tjernlund (3):
>   powerpc, 8xx: Fix fallout from "Fixup all 8xx u-boot.lds scripts"
>   Fix a few gcc warnings.
>   powerpc, 8xx: adapt a few linker scripts so it will build.

What do you mean with "will build again"?

You are aware that the problemativ patch has been reverted, aren't
you?

Best regards,

Wolfgang Denk
Joakim Tjernlund April 24, 2011, 2:41 p.m. UTC | #5
Wolfgang Denk <wd@denx.de> wrote on 2011/04/24 16:30:14:
>
> Dear Joakim Tjernlund,
>
> In message <1303633774-22961-1-git-send-email-Joakim.Tjernlund@transmode.se> you wrote:
> > With these patches 8xx willbuild again for me
> > with a number of gcc's even with "Add support for -msingle-pic-base"
> > I hope WD's gcc will also work.
> >
> > Joakim Tjernlund (3):
> >   powerpc, 8xx: Fix fallout from "Fixup all 8xx u-boot.lds scripts"
> >   Fix a few gcc warnings.
> >   powerpc, 8xx: adapt a few linker scripts so it will build.
>
> What do you mean with "will build again"?
>
> You are aware that the problemativ patch has been reverted, aren't
> you?

Yes, but I have it here locally. With it and any compiler I have handy, the problematic
board builds OK. It just needs to pass your gcc as well :)
Probably you could just test these new patches as is and if that works well, could you
try "unreverting" the problematic patch again?

 Jocke
Wolfgang Denk April 24, 2011, 5:11 p.m. UTC | #6
Dear Joakim Tjernlund,

In message <OFCB7A24F0.EBD815BE-ONC125787C.005061DD-C125787C.0050B36F@transmode.se> you wrote:
>
> Yes, but I have it here locally. With it and any compiler I have handy, the problematic
> board builds OK. It just needs to pass your gcc as well :)
> Probably you could just test these new patches as is and if that works well, could you
> try "unreverting" the problematic patch again?

I can try for test purposes, but if it works, I would rather like to
see a single patch that implkements this correctly in a single commit
so we maintain bisectability.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/board/LEOX/elpt860/u-boot.lds b/board/LEOX/elpt860/u-boot.lds
index 45206ca..5aaf6b3 100644
--- a/board/LEOX/elpt860/u-boot.lds
+++ b/board/LEOX/elpt860/u-boot.lds
@@ -67,13 +67,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/RPXClassic/u-boot.lds b/board/RPXClassic/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/RPXClassic/u-boot.lds
+++ b/board/RPXClassic/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/RPXlite/u-boot.lds b/board/RPXlite/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/RPXlite/u-boot.lds
+++ b/board/RPXlite/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/RPXlite_dw/u-boot.lds b/board/RPXlite_dw/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/RPXlite_dw/u-boot.lds
+++ b/board/RPXlite_dw/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/RRvision/u-boot.lds b/board/RRvision/u-boot.lds
index 3e7853a..8385373 100644
--- a/board/RRvision/u-boot.lds
+++ b/board/RRvision/u-boot.lds
@@ -52,13 +52,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/adder/u-boot.lds b/board/adder/u-boot.lds
index 661a94a..a762769 100644
--- a/board/adder/u-boot.lds
+++ b/board/adder/u-boot.lds
@@ -43,13 +43,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_) >> 2;

   .data    :
diff --git a/board/amirix/ap1000/u-boot.lds b/board/amirix/ap1000/u-boot.lds
index 57fe1d9..cd8f5ce 100644
--- a/board/amirix/ap1000/u-boot.lds
+++ b/board/amirix/ap1000/u-boot.lds
@@ -49,13 +49,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/c2mon/u-boot.lds b/board/c2mon/u-boot.lds
index 524c36e..b9b8e3c 100644
--- a/board/c2mon/u-boot.lds
+++ b/board/c2mon/u-boot.lds
@@ -55,13 +55,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/cogent/u-boot.lds b/board/cogent/u-boot.lds
index e324f5c..2393d8d 100644
--- a/board/cogent/u-boot.lds
+++ b/board/cogent/u-boot.lds
@@ -51,13 +51,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/dave/PPChameleonEVB/u-boot.lds b/board/dave/PPChameleonEVB/u-boot.lds
index 20c32b7..3b10114 100644
--- a/board/dave/PPChameleonEVB/u-boot.lds
+++ b/board/dave/PPChameleonEVB/u-boot.lds
@@ -55,9 +55,10 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
diff --git a/board/eltec/mhpc/u-boot.lds b/board/eltec/mhpc/u-boot.lds
index 2fac727..fd4e8a5 100644
--- a/board/eltec/mhpc/u-boot.lds
+++ b/board/eltec/mhpc/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/emk/top860/u-boot.lds b/board/emk/top860/u-boot.lds
index 32dcbd3..fb06648 100644
--- a/board/emk/top860/u-boot.lds
+++ b/board/emk/top860/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/ep88x/u-boot.lds b/board/ep88x/u-boot.lds
index e2dd1c2..332b35a 100644
--- a/board/ep88x/u-boot.lds
+++ b/board/ep88x/u-boot.lds
@@ -43,9 +43,10 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
diff --git a/board/esd/dasa_sim/u-boot.lds b/board/esd/dasa_sim/u-boot.lds
index 2bf60f5..b15948d 100644
--- a/board/esd/dasa_sim/u-boot.lds
+++ b/board/esd/dasa_sim/u-boot.lds
@@ -54,13 +54,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/esteem192e/u-boot.lds b/board/esteem192e/u-boot.lds
index 8455f0b..163b83d 100644
--- a/board/esteem192e/u-boot.lds
+++ b/board/esteem192e/u-boot.lds
@@ -56,13 +56,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/etx094/u-boot.lds b/board/etx094/u-boot.lds
index 04233d8..b68d9ea 100644
--- a/board/etx094/u-boot.lds
+++ b/board/etx094/u-boot.lds
@@ -56,13 +56,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/evb64260/u-boot.lds b/board/evb64260/u-boot.lds
index 0648f62..2d031ef 100644
--- a/board/evb64260/u-boot.lds
+++ b/board/evb64260/u-boot.lds
@@ -51,13 +51,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/fads/u-boot.lds b/board/fads/u-boot.lds
index 63d0ea1..9ea0674 100644
--- a/board/fads/u-boot.lds
+++ b/board/fads/u-boot.lds
@@ -49,13 +49,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/flagadm/u-boot.lds b/board/flagadm/u-boot.lds
index 2fac727..fd4e8a5 100644
--- a/board/flagadm/u-boot.lds
+++ b/board/flagadm/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/gen860t/u-boot.lds b/board/gen860t/u-boot.lds
index 8e854db..be99b51 100644
--- a/board/gen860t/u-boot.lds
+++ b/board/gen860t/u-boot.lds
@@ -52,13 +52,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/genietv/u-boot.lds b/board/genietv/u-boot.lds
index 3e396e4..1d66a9b 100644
--- a/board/genietv/u-boot.lds
+++ b/board/genietv/u-boot.lds
@@ -61,13 +61,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/hermes/u-boot.lds b/board/hermes/u-boot.lds
index d50c586..ca97115 100644
--- a/board/hermes/u-boot.lds
+++ b/board/hermes/u-boot.lds
@@ -53,13 +53,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/hymod/u-boot.lds b/board/hymod/u-boot.lds
index 1592f4f..1efa8b3 100644
--- a/board/hymod/u-boot.lds
+++ b/board/hymod/u-boot.lds
@@ -93,7 +93,7 @@  SECTIONS
     _FIXUP_TABLE_ = .;
     *(.fixup)
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/icu862/u-boot.lds b/board/icu862/u-boot.lds
index cb5afc1..93c79a6 100644
--- a/board/icu862/u-boot.lds
+++ b/board/icu862/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/ip860/u-boot.lds b/board/ip860/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/ip860/u-boot.lds
+++ b/board/ip860/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/ivm/u-boot.lds b/board/ivm/u-boot.lds
index ff7012a..1e843eb 100644
--- a/board/ivm/u-boot.lds
+++ b/board/ivm/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/kup/kup4k/u-boot.lds b/board/kup/kup4k/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/kup/kup4k/u-boot.lds
+++ b/board/kup/kup4k/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/kup/kup4x/u-boot.lds b/board/kup/kup4x/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/kup/kup4x/u-boot.lds
+++ b/board/kup/kup4x/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/lantec/u-boot.lds b/board/lantec/u-boot.lds
index 25e7a4d..de0b355 100644
--- a/board/lantec/u-boot.lds
+++ b/board/lantec/u-boot.lds
@@ -56,13 +56,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/lwmon/u-boot.lds b/board/lwmon/u-boot.lds
index d02db17..8bf7324 100644
--- a/board/lwmon/u-boot.lds
+++ b/board/lwmon/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/manroland/uc100/u-boot.lds b/board/manroland/uc100/u-boot.lds
index 344cbde..731cec9 100644
--- a/board/manroland/uc100/u-boot.lds
+++ b/board/manroland/uc100/u-boot.lds
@@ -50,13 +50,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/matrix_vision/mvsmr/u-boot.lds b/board/matrix_vision/mvsmr/u-boot.lds
index f3d01e7..bf2ed04 100644
--- a/board/matrix_vision/mvsmr/u-boot.lds
+++ b/board/matrix_vision/mvsmr/u-boot.lds
@@ -55,9 +55,10 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
diff --git a/board/mbx8xx/u-boot.lds b/board/mbx8xx/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/mbx8xx/u-boot.lds
+++ b/board/mbx8xx/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/ml2/u-boot.lds b/board/ml2/u-boot.lds
index 0f2593d..9f9ddb8 100644
--- a/board/ml2/u-boot.lds
+++ b/board/ml2/u-boot.lds
@@ -44,13 +44,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/mousse/u-boot.lds b/board/mousse/u-boot.lds
index ef73e2b..dae2cfc 100644
--- a/board/mousse/u-boot.lds
+++ b/board/mousse/u-boot.lds
@@ -41,13 +41,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_) >> 2;

   .data    :
diff --git a/board/mvblue/u-boot.lds b/board/mvblue/u-boot.lds
index 03ba155..11624d2 100644
--- a/board/mvblue/u-boot.lds
+++ b/board/mvblue/u-boot.lds
@@ -51,13 +51,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_) >> 2;

   .data    :
diff --git a/board/netphone/u-boot.lds b/board/netphone/u-boot.lds
index b7b6c1a..a949e4f 100644
--- a/board/netphone/u-boot.lds
+++ b/board/netphone/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/netta/u-boot.lds b/board/netta/u-boot.lds
index b7b6c1a..a949e4f 100644
--- a/board/netta/u-boot.lds
+++ b/board/netta/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/netta2/u-boot.lds b/board/netta2/u-boot.lds
index b7b6c1a..a949e4f 100644
--- a/board/netta2/u-boot.lds
+++ b/board/netta2/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/netvia/u-boot.lds b/board/netvia/u-boot.lds
index b7b6c1a..a949e4f 100644
--- a/board/netvia/u-boot.lds
+++ b/board/netvia/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/nx823/u-boot.lds b/board/nx823/u-boot.lds
index 2fac727..fd4e8a5 100644
--- a/board/nx823/u-boot.lds
+++ b/board/nx823/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/quantum/u-boot.lds b/board/quantum/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/quantum/u-boot.lds
+++ b/board/quantum/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/r360mpi/u-boot.lds b/board/r360mpi/u-boot.lds
index 60b3cbf..2fa085a 100644
--- a/board/r360mpi/u-boot.lds
+++ b/board/r360mpi/u-boot.lds
@@ -49,13 +49,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/rbc823/u-boot.lds b/board/rbc823/u-boot.lds
index 7b790ab..d943fb6 100644
--- a/board/rbc823/u-boot.lds
+++ b/board/rbc823/u-boot.lds
@@ -58,13 +58,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/rmu/u-boot.lds b/board/rmu/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/rmu/u-boot.lds
+++ b/board/rmu/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/rsdproto/u-boot.lds b/board/rsdproto/u-boot.lds
index b36047a..81728db 100644
--- a/board/rsdproto/u-boot.lds
+++ b/board/rsdproto/u-boot.lds
@@ -80,7 +80,7 @@  SECTIONS
     _FIXUP_TABLE_ = .;
     *(.fixup)
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/sandpoint/u-boot.lds b/board/sandpoint/u-boot.lds
index 841a29b..e382fd1 100644
--- a/board/sandpoint/u-boot.lds
+++ b/board/sandpoint/u-boot.lds
@@ -49,13 +49,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_) >> 2;

   .data    :
diff --git a/board/sc3/u-boot.lds b/board/sc3/u-boot.lds
index 2cbbca5..4db46ca 100644
--- a/board/sc3/u-boot.lds
+++ b/board/sc3/u-boot.lds
@@ -96,13 +96,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    *(.got)
     _GOT2_TABLE_ = .;
     *(.got2)
+    *(.got)
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     *(.fixup)
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/siemens/IAD210/u-boot.lds b/board/siemens/IAD210/u-boot.lds
index 725bef8..0e78e4f 100644
--- a/board/siemens/IAD210/u-boot.lds
+++ b/board/siemens/IAD210/u-boot.lds
@@ -56,13 +56,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/sixnet/u-boot.lds b/board/sixnet/u-boot.lds
index 2711f2c..02d1980 100644
--- a/board/sixnet/u-boot.lds
+++ b/board/sixnet/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/snmc/qs850/u-boot.lds b/board/snmc/qs850/u-boot.lds
index 007ae00..9ab248a 100644
--- a/board/snmc/qs850/u-boot.lds
+++ b/board/snmc/qs850/u-boot.lds
@@ -50,13 +50,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/snmc/qs860t/u-boot.lds b/board/snmc/qs860t/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/snmc/qs860t/u-boot.lds
+++ b/board/snmc/qs860t/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/spc1920/u-boot.lds b/board/spc1920/u-boot.lds
index 05cc233..d0b60cf 100644
--- a/board/spc1920/u-boot.lds
+++ b/board/spc1920/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/spd8xx/u-boot.lds b/board/spd8xx/u-boot.lds
index 796c283..950e1e6 100644
--- a/board/spd8xx/u-boot.lds
+++ b/board/spd8xx/u-boot.lds
@@ -57,13 +57,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/stx/stxxtc/u-boot.lds b/board/stx/stxxtc/u-boot.lds
index b7b6c1a..a949e4f 100644
--- a/board/stx/stxxtc/u-boot.lds
+++ b/board/stx/stxxtc/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/svm_sc8xx/u-boot.lds b/board/svm_sc8xx/u-boot.lds
index c4ce968..c65f022 100644
--- a/board/svm_sc8xx/u-boot.lds
+++ b/board/svm_sc8xx/u-boot.lds
@@ -63,13 +63,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/tqc/tqm8xx/u-boot.lds b/board/tqc/tqm8xx/u-boot.lds
index 83a09b0..f625c3d 100644
--- a/board/tqc/tqm8xx/u-boot.lds
+++ b/board/tqc/tqm8xx/u-boot.lds
@@ -63,13 +63,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/v37/u-boot.lds b/board/v37/u-boot.lds
index 578a49b..e62d53d 100644
--- a/board/v37/u-boot.lds
+++ b/board/v37/u-boot.lds
@@ -47,13 +47,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :
diff --git a/board/westel/amx860/u-boot.lds b/board/westel/amx860/u-boot.lds
index 3514a66..3470b43 100644
--- a/board/westel/amx860/u-boot.lds
+++ b/board/westel/amx860/u-boot.lds
@@ -56,13 +56,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    KEEP(*(.got))
     _GOT2_TABLE_ = .;
     KEEP(*(.got2))
+    KEEP(*(.got))
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     KEEP(*(.fixup))
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_)>>2;

   .data    :