Bug 2065

Summary: "ld -r" is broken
Product: binutils Reporter: H.J. Lu <hjl.tools>
Component: ldAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: amodra, bug-binutils
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target: ia64-linux
Build: Last reconfirmed:
Attachments: A testcase

Description H.J. Lu 2005-12-18 15:20:58 UTC
I rebuilt 2.4.21-37.EL ia64 kernel with 20051214 binutils. I got
several problems:

1. vfat kernel module won't load:

# modprobe vfat
/lib/modules/2.4.21-37.EL.1.2/kernel/fs/vfat/vfat.o: init_module:
Invalid argument
Hint: insmod errors can be caused by incorrect module parameters,
including invalid IO or IRQ parameters.
      You may find more information in syslog or the output from dmesg
      /lib/modules/2.4.21-37.EL.1.2/kernel/fs/vfat/vfat.o: insmod
      /lib/modules/2.4.21-37.EL.1.2/kernel/fs/vfat/vfat.o failed
      /lib/modules/2.4.21-37.EL.1.2/kernel/fs/vfat/vfat.o: insmod vfat
      failed

module_arch_init: archdata->segment_base out of bounds.

2. autofs doesn't work:

Dec 16 15:28:47 gnu-12 automount[3723]: mount(nfs): mkdir_path
/net/gnu-20/export failed: Operation not permitted
Comment 1 H.J. Lu 2005-12-18 15:23:40 UTC
Created attachment 807 [details]
A testcase

I believe it is caused by

http://sourceware.org/ml/binutils/2005-11/msg00350.html

I am enclosing a tar file. There are good.o and bad.o, which are
generated by

# ld -o [good.o|bad.o] -r namei.o vfatfs_syms.o

bad.o is generated by the new linker.
Comment 2 H.J. Lu 2005-12-18 17:50:44 UTC
I have verified that

http://sourceware.org/ml/binutils/2005-11/msg00239.html

is the real cause. It changes the output of "ld -r" from

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000005130  0000000000000000  AX       0     0     32
  [ 2] .rela.text        RELA             0000000000000000  00005f60
       00000000000011e8  0000000000000018          14     1     8
  [ 3] .modinfo          PROGBITS         0000000000000000  00005170
       0000000000000032  0000000000000000   A       0     0     8
  [ 4] .rodata.str1.8    PROGBITS         0000000000000000  000051a8
       000000000000024c  0000000000000001 AMS       0     0     8
...

to

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .modinfo          PROGBITS         0000000000000000  00000040
       0000000000000032  0000000000000000   A       0     0     8
  [ 2] .rodata.str1.8    PROGBITS         0000000000000000  00000078
       000000000000024c  0000000000000001 AMS       0     0     8
  [ 3] .text             PROGBITS         0000000000000000  000002e0
       0000000000005130  0000000000000000  AX       0     0     32
  [ 4] .rela.text        RELA             0000000000000000  00005f78
       00000000000011e8  0000000000000018          14     3     8
Comment 3 H.J. Lu 2005-12-18 22:18:52 UTC
That is incorrect. The "prev" field set by

+  ret->os.prev = &((*lang_output_section_statement.tail)
+		   ->output_section_statement);

is always NULL since tail points the next field of the last element on the list.
Comment 4 H.J. Lu 2005-12-19 05:58:56 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2005-12/msg00153.html
Comment 5 H.J. Lu 2005-12-31 16:40:00 UTC
It is fixed by

http://sourceware.org/ml/binutils/2005-12/msg00225.html