realocatable code

Gerhard TAEUBL GTaeubl@frequentis.com
Mon Jan 22 02:21:00 GMT 2001


Hallo!
I have to compiled code realocate able. So I use the following 
makefile:
 
$(BUILD_DIR)/%.o: %.c  $(CC) -g -c -Wall -W -mrelocatable -o 
$@ $< 
 
$(BUILD_DIR)/%.o : %.s  $(AS) -o $@ $< 
 
$(ELF_FILE): $(O_FILES) ../src/$(LINK_FILE)  $(LD) 
-nostartfiles -T ../src/$(LINK_FILE) -Map 
$(MAP_FILE)\        -o $(ELF_FILE) 
$(O_FILES)
 
$(TMP_FILE): $(ELF_FILE)  $(OBJCOPY) --strip-all --strip-debug 
--remove-section .comment\     --output-target binary 
$(ELF_FILE) $(TMP_FILE)
 
$(BIN_FILE): $(TMP_FILE)  $(PERL) $(MODCRC32) $(TMP_FILE) 
$(BUILD_DIR)/lmodule.tmp  $(PERL) $(SBUS_DL) $(BUILD_DIR)/lmodule.tmp 
$(BIN_FILE)  $(RM) $(BUILD_DIR)/lmodule.tmp $(TMP_FILE)
 Well this works fine with:
as 2.8.1
gcc 2.7.2.1
ld 2.8.1
(I know this compiler is a little bit too old.. :-) )
Then I update to:
as 2.9.1
gcc 2.91.57
ld 2.9.1
 
After that I get an error message:
/project/v4/software/ext-tools/egcs-1.1b-newlib/bin/powerpc-eabi-gcc -g 
-c -Wall -W -mrelocatable -o ../build/lmodule.o lmodule.c lmodule.c: In function 
`EventHandler': lmodule.c:267: warning: unused parameter 
`Event' /project/v4/software/ext-tools/egcs-1.1b-newlib/bin/powerpc-eabi-as 
-o ../build/iotable.o iotable.s 
/project/v4/software/ext-tools/egcs-1.1b-newlib/bin/powerpc-eabi-ld 
-nostartfiles -r -T ../src/lmodule.lnk -Map 
../build/lmodule.map\       -o 
../build/lmodule.elf  ../build/lmodule.o  
../build/iotable.o /project/v4/software/ext-tools/egcs-1.1b-newlib/bin/powerpc-eabi-ld: 
../build/lmodule.o: compiled with -mrelocatable and linked with modules compiled 
normally Bad value: failed to merge target specific data of file 
../build/lmodule.o make: *** [../build/lmodule.elf] Error 1
If I use the old linker everthing is fine, so whats wrong?
 
Here is the linker file:
ENTRY( InitModule)
 
OUTPUT_FORMAT("elf32-powerpc", 
"elf32-powerpc",               
"elf32-powerpc") OUTPUT_ARCH(powerpc)
 
SECTIONS {    .iotable :    
{       
../build/iotable.o(.data)         
}
 
   .text :    
{       
../build/lmodule.o(.text)       
*(.text)       /* .gnu.warning sections are handled 
specially by elf32.em.  */       
*(.gnu.warning)    } =0
 
__IMAGE_START = ADDR(.text); __TSTRAM_START = 
__IMAGE_START;
 
   
.init              
: { *(.init)          } 
=0    
.fini              
: { *(.fini)          } 
=0
 
   /* Read-only sections, merged into text segment: 
*/    
.interp            : { 
*(.interp)        }    
.hash              
: { *(.hash)          
}    
.dynsym            : { 
*(.dynsym)        }    
.dynstr            : { 
*(.dynstr)        }    
.rela.text         : { 
*(.rela.text)     }    
.rela.data         : { 
*(.rela.data)     }    
.rela.rodata       : { *(.rela.rodata)   
}    
.rela.got          : { 
*(.rela.got)      }    
.rela.got1         : { 
*(.rela.got1)     }    
.rela.got2         : { 
*(.rela.got2)     }    
.rela.ctors        : { 
*(.rela.ctors)    }    
.rela.dtors        : { 
*(.rela.dtors)    }    
.rela.init         : { 
*(.rela.init)     }    
.rela.fini         : { 
*(.rela.fini)     }    
.rela.bss          : { 
*(.rela.bss)      }    
.rela.plt          : { 
*(.rela.plt)      }    
.rela.sdata        : { 
*(.rela.sdata2)   }    
.rela.sbss         : { 
*(.rela.sbss2)    }    
.rela.sdata2       : { *(.rela.sdata2)   
}    .rela.sbss2        : { 
*(.rela.sbss2)    }    
.plt               
: { *(.plt)           
}
 
   
.rodata            : { 
*(.rodata)        }    
.rodata1           : { 
*(.rodata1)       }
 
   
.sdata2            : { 
*(.sdata2)        }    
.sbss2             : 
{ *(.sbss2)         }
 
__DATA_RAM = .; __DATA_ROM = __DATA_RAM;
 
   
.data              
:    {       
*(.data)       CONSTRUCTORS    
}    
.data1             : 
{ *(.data1)         }    
.got1              
: { *(.got1)          
}    
.dynamic           : { 
*(.dynamic)       }    /* Put .ctors 
and .dtors next to the .got2 section, so that the 
pointers       get relocated with -mrelocatable. 
Also put in the .fixup pointers.       The current 
compiler no longer needs this, but keep it around for 2.7.2  
*/    PROVIDE (_GOT2_START_ = .);    
.got2              
:  { *(.got2)         
}    PROVIDE (__CTOR_LIST__ = .);    
.ctors             : 
{ *(.ctors)         }    
PROVIDE (__CTOR_END__ = .);    PROVIDE (__DTOR_LIST__ = 
.);    
.dtors             : 
{ *(.dtors)         }    
PROVIDE (__DTOR_END__ = .);    PROVIDE (_FIXUP_START_ = 
.);    
.fixup             : 
{ *(.fixup)         }    
PROVIDE (_FIXUP_END_ = .);    PROVIDE (_GOT2_END_ = 
.);    PROVIDE (_GOT_START_ = .);    
.got               
: { *(.got)           
}    
.got.plt           : { 
*(.got.plt)       }    PROVIDE 
(_GOT_END_ = .);    /* We want the small data sections together, so 
single-instruction offsets       can access them 
all, and initialized data all before uninitialized, 
so       we can shorten the on-disk segment 
size.  */    
.sdata             : 
{ *(.sdata)         }
 
__DATA_END      = 
.; __IMAGE_SIZE    = __DATA_END - 
__IMAGE_START; __BSS_START     = .;
 
   
.sbss              
:    {       
*(.sbss)       *(.scommon)    
}    
.bss               
:    {       
*(.dynbss)       
*(.bss)       *(COMMON)    }
 
__BSS_END       = .;
 
   /* These are needed for ELF backends which have not yet 
been       converted to the new style linker.  
*/    
.stab           0  : { 
*(.stab)          }    
.stabstr        0  : { 
*(.stabstr)       }
 
   /* DWARF debug sections.       
Symbols in the .debug DWARF section are relative to the beginning of 
the       section so we begin .debug at 0.  
It's not clear yet what needs to happen       for 
the others.   */    
.debug          0 : { 
*(.debug)          
}    .debug_srcinfo  0 : { *(.debug_srcinfo)  
}    .debug_aranges  0 : { *(.debug_aranges)  
}    .debug_pubnames 0 : { *(.debug_pubnames) }    
.debug_sfnames  0 : { *(.debug_sfnames)  }    
.line           0 : { 
*(.line)           
} }
 
Could anyone help me?
Thanks
Gerhard




More information about the Gcc-help mailing list