Bug 13391 - .rofixup section size mismatch
Summary: .rofixup section size mismatch
Status: ASSIGNED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-07 15:51 UTC by Stuart Henderson
Modified: 2021-01-17 18:01 UTC (History)
3 users (show)

See Also:
Host:
Target: bfin-linux-uclibc
Build:
Last reconfirmed:


Attachments
gcc verbose linker output (3.36 KB, text/plain)
2018-01-08 18:12 UTC, wbx
Details
crtbegin.o object file (912 bytes, application/x-object)
2018-01-08 18:13 UTC, wbx
Details
crtbeginS.o object file (996 bytes, application/x-object)
2018-01-08 18:14 UTC, wbx
Details
crtend.o object file (501 bytes, application/x-object)
2018-01-08 18:14 UTC, wbx
Details
crtendS.o object file (501 bytes, application/x-object)
2018-01-08 18:15 UTC, wbx
Details
libgcc.a static archive (22.61 KB, application/x-archive)
2018-01-08 18:15 UTC, wbx
Details
libgcc_eh.a static archive (12.79 KB, application/x-archive)
2018-01-08 18:16 UTC, wbx
Details
ld-uClibc.so shared library loader (13.96 KB, application/x-sharedlib)
2018-01-08 18:16 UTC, wbx
Details
libuClibc.so shared library (233.19 KB, application/x-sharedlib)
2018-01-08 18:17 UTC, wbx
Details
test.o object file (5.96 KB, application/x-object)
2018-01-08 18:24 UTC, wbx
Details
Proposed patch (365 bytes, patch)
2018-01-09 14:37 UTC, Nick Clifton
Details | Diff
regression introduced by patch (359 bytes, text/plain)
2018-01-09 21:29 UTC, wbx
Details
Proposed patch (336 bytes, patch)
2018-01-12 11:06 UTC, Nick Clifton
Details | Diff
regression introduced by second patch (3.61 KB, text/plain)
2018-01-12 20:37 UTC, wbx
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Henderson 2011-11-07 15:51:12 UTC
I'm looking into a problem I'm seeing with the Blackfin linker (binutils 2.21 & HEAD) when I move to gcc-4.5 (from gcc-4.3).  When compiling the example at the bottom (-O3 -g FDPIC), I get the following error:
bin/ld: LINKER BUG: .rofixup section size mismatch
bin/ld: final link failed: Nonrepresentable section on output

i.e. the fixup section size is smaller than the fixup relocation count * 4.

The problem appears to be caused by gcc 4.5's emission of a series of:
.picptr funcdesc(_callback)
in the .debug_info section which aren't being handled correctly.

I can workaround the error by just not counting relocsfd for R_BFIN_FUNCDESCs in sections without the SEC_ALLOC flag, but this doesn't seem like the appropriate fix.

Example:

static int CallFunctionRec(int (*fun)()) {
  CallFunctionRec(fun);
  return 1;
}

static int CallFunction(int (*fun)()) {
  return CallFunctionRec(fun);
}

static int callback() {
  return 0;
}

int main() {
  CallFunction(callback);
  return 0;
}
Comment 1 wbx 2018-01-07 19:36:16 UTC
Anything can be done to fix this bug?
It still happening with the test case and binutils git from today.

wbx@gcc76:~/bfin$ ./toolchain_sim-bfin_uclibc-ng_bf512_fdpic/usr/bin/bfin-openadk-linux-uclibc-gcc -o test test.c
wbx@gcc76:~/bfin$ ./toolchain_sim-bfin_uclibc-ng_bf512_fdpic/usr/bin/bfin-openadk-linux-uclibc-gcc -g3 -o test test.c
wbx@gcc76:~/bfin$ ./toolchain_sim-bfin_uclibc-ng_bf512_fdpic/usr/bin/bfin-openadk-linux-uclibc-gcc -O3 -g3 -o test test.c
/home/wbx/bfin/toolchain_sim-bfin_uclibc-ng_bf512_fdpic/usr/lib/gcc/bfin-openadk-linux-uclibc/7.2.0/../../../../bfin-openadk-linux-uclibc/bin/ld: LINKER BUG: .rofixup section size mismatch
/home/wbx/bfin/toolchain_sim-bfin_uclibc-ng_bf512_fdpic/usr/lib/gcc/bfin-openadk-linux-uclibc/7.2.0/../../../../bfin-openadk-linux-uclibc/bin/ld: final link failed: Nonrepresentable section on output

It triggers a lot of build failures in the Buildroot autobuilders.
Comment 2 Nick Clifton 2018-01-08 11:19:30 UTC
(In reply to wbx from comment #1)

> Anything can be done to fix this bug?
> It still happening with the test case and binutils git from today.

Can you provide a testcase which I could examine ?

I know that the original report include a C source code example,
but I do not have access to a bfin compiler or system libraries.
An object file, minimal set of libraries and a linker command line
would be really helpful.

Cheers
  Nick
Comment 3 wbx 2018-01-08 18:12:54 UTC
Created attachment 10713 [details]
gcc verbose linker output

gcc -Wl,-verbose output
Comment 4 wbx 2018-01-08 18:13:50 UTC
Created attachment 10714 [details]
crtbegin.o object file
Comment 5 wbx 2018-01-08 18:14:14 UTC
Created attachment 10715 [details]
crtbeginS.o object file
Comment 6 wbx 2018-01-08 18:14:36 UTC
Created attachment 10716 [details]
crtend.o object file
Comment 7 wbx 2018-01-08 18:15:04 UTC
Created attachment 10717 [details]
crtendS.o object file
Comment 8 wbx 2018-01-08 18:15:57 UTC
Created attachment 10718 [details]
libgcc.a static archive
Comment 9 wbx 2018-01-08 18:16:18 UTC
Created attachment 10719 [details]
libgcc_eh.a static archive
Comment 10 wbx 2018-01-08 18:16:43 UTC
Created attachment 10720 [details]
ld-uClibc.so shared library loader
Comment 11 wbx 2018-01-08 18:17:21 UTC
Created attachment 10721 [details]
libuClibc.so shared library
Comment 12 wbx 2018-01-08 18:24:16 UTC
Created attachment 10722 [details]
test.o object file
Comment 13 wbx 2018-01-08 18:25:47 UTC
Hi Nick,

all attached.

best regards
 Waldemar
Comment 14 Nick Clifton 2018-01-09 14:37:15 UTC
Created attachment 10723 [details]
Proposed patch

Hi Waldemar,

  Please try out this patch and let me know if it works for you.

Cheers
  Nick

PS.  It probably needs testing on some real programs as well as
just the simple test case...
Comment 15 wbx 2018-01-09 21:27:17 UTC
Hi Nick,

I just rebuild binutils with the patch and the testcase compiled.
But afterwards I have done a complete rebuild of toolchain and base system and
attached regression appeared (double checked with and without patch)
while compiling uClibc-ng utils (ldd, ldconfig, ..) for target use.

best regards
 Waldemar
Comment 16 wbx 2018-01-09 21:29:33 UTC
Created attachment 10725 [details]
regression introduced by patch
Comment 17 Nick Clifton 2018-01-10 11:23:12 UTC
Hi Waldemar,

  *sigh* I suspected that something like this might happen.

  Please can you send me a reproducer for the new failure
  so that I can investigate ?

Cheers
  Nick
Comment 18 wbx 2018-01-12 02:53:08 UTC
Hi Nick,
A link to all files is okay?
https://debug.openadk.org/bfin/

best regards
 Waldemar
Comment 19 Nick Clifton 2018-01-12 11:06:01 UTC
Created attachment 10729 [details]
Proposed patch

Hi Waldemar,

  Thanks - that worked and I could reproduce the new failure.
  I am clutching at straws a bit here, but please could you
  try out the revised patch attached ?  It works for me, but
  that is not saying much...

Cheers
  Nick
Comment 20 wbx 2018-01-12 20:35:56 UTC
Hi Nick,
It is getting better, the testcase works, the uClibc utils are compilable, but 
compilation of busybox fails now.
See regression2.txt.

best regards
 Waldemar
Comment 21 wbx 2018-01-12 20:37:09 UTC
Created attachment 10730 [details]
regression introduced by second patch
Comment 22 Nick Clifton 2018-01-16 10:53:38 UTC
Hi Waldemar,

> It is getting better, the testcase works, the uClibc utils are compilable,
> but compilation of busybox fails now.

*sigh*.  OK, I will take a look, but it may not be for a little while
as I am busy with the 2.30 release at the moment.

Cheers
  Nick
Comment 23 wbx 2018-01-31 06:00:04 UTC
Hi Nick,

I can provide you shell access to a server with all stuff precompiled
showing the error if you want?

best regards
 Waldemar
Comment 24 Nick Clifton 2018-02-09 14:10:05 UTC
Hi Waldemar,

> I can provide you shell access to a server with all stuff precompiled
> showing the error if you want?

Can you send me another tarball of objects/libraries please ?  And the linker command line.  (It is much easier for me to debug things locally).

Cheers
  Nick
Comment 25 wbx 2018-04-22 19:07:15 UTC
Hi Nick,

sorry for the long timeout.
Here you find the objects and libraries:
https://debug.openadk.org/bfin-report/

Binutils git from today.
bb.tar.gz contains the busybox objects.
u.tar.gz contains uClibc-ng/gcc objects and libraries.
foo.sh is the compile step and foo.log the verbose output.

best regards
 Waldemar