berkus / mclinker

Automatically exported from code.google.com/p/mclinker
Other
0 stars 0 forks source link

start-group error still exists #141

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Sample file:
#include <stdio.h>

int main () {
  puts("hi\n");
  return 0;
}

Compile this and link it the object with all necessary files such as crt0, 
init, fini etc in normal link line. It'll have all sections right. However if 
you put the entire object list and library list along with the -L option inside 
--start-group and --end-group such as:
ld.mcld -march=x86 --start-group a.o crt0.o -lc -L/lib .... --end-group 

This will not cause the linker to segfault as it previously did before Diana's 
fix about iterator de-referencing group node. However, the final binary will 
have all sections missing from it:
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - Linux
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          288 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         3
  Size of section headers:           40 (bytes)
  Number of section headers:         5
  Section header string table index: 1

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .shstrtab         STRTAB          00000000 000094 00002b 00      0   0  1
  [ 2] .symtab           SYMTAB          00000000 0000c0 000040 10      4   1  4
  [ 3] .note.GNU-stack   PROGBITS        00000000 000100 000000 00      0   0  1
  [ 4] .strtab           STRTAB          00000000 000100 000019 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00060 0x00060 R   0x4
  LOAD           0x000000 0x08048000 0x08048000 0x00000 0xf7fb8000 R   0x1000
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02

I think the problem is not completely addressed by revision eb25064b4f36.

Original issue reported on code.google.com by khem...@codeaurora.org on 24 Apr 2013 at 10:23

GoogleCodeExporter commented 9 years ago
A note that I forgot to add: GNU ld behaves perfectly normal when this kind of 
link line with all objects, libraries and supporting attributes to them are  
encapsulated inside a start-group and end-group.

Original comment by khem...@codeaurora.org on 24 Apr 2013 at 10:36

GoogleCodeExporter commented 9 years ago

Original comment by mysekki on 26 Apr 2013 at 6:30

GoogleCodeExporter commented 9 years ago
Fix at Revision: 8364c44dd175. Please check. Thank you.

Original comment by mysekki on 26 Apr 2013 at 7:33