views:

178

answers:

4

I'm getting a link time error:

WARNING: /home/gulevich/development/camac-fedorov/camac/linux/k0607-lsi6/camac-k0607-lsi6.o (.ctors): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

The code causing the error (assembly in C source):

# if   defined(__ELF__)
#  define __SECTION_FLAGS ", \"aw\" , @progbits"
 /* writable flag needed for ld ".[cd]tors" sections bug workaround) */
# elif defined(__COFF__)
#  define __SECTION_FLAGS ", \"dr\""
 /* untested, may be writable flag needed */
# endif


asm
(
 ".section .ctors" __SECTION_FLAGS "\n"
 ".globl __ctors_begin__\n"
 "__ctors_begin__:\n"
 ".previous\n"
);

Is there any way to fix this? The idea is to put a varaible __ctors_begin__ at the beginning of a certain memory section. This code is a legacy that worked fine using a different build system and older compiler.

Meaning of this assembly code explained in an answer to my previous question.

A: 

A long shot: Perhaps your linker is expecting ELF format (instead of COFF), and for some reason __ELF__ is not defined? Have you checked the preprocessor output for this particular build?

Schedler
A: 

I would dobule check the value of __SECTION_FLAGS just to be sure that it indeed contains ax or aw. I'd also be sure that __COFF__ is not defined and that __ELF__ is. Failing that, it might be time to grab (is possible) a previous or future version of the compiler/linker and see if that fixes your problem. Perhaps you could compile your code as C++ and somehow let the compiler/linker/link scritps do what they are supposed to do? Dunno completely, but this is where I would start.

Michael Dorgan
+1  A: 

very long shot but is the section .ctors is defined like you want in the linker script? ld iirc has a verbose option to show the linker script.

plaisthos
A: 

Sections work fine. So I'll ignore this warning.

Basilevs