Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory section handling error

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.

like image 301
Basilevs Avatar asked Apr 16 '10 05:04

Basilevs


People also ask

How to solve memory error in C?

delete s; To avoid mismatched allocation/deallocation, ensure that the right deallocator is called. In C++, new[] is used for memory allocation and delete[] for freeing up. In C, malloc(), calloc() and realloc() functions are used for allocating memory while the free() function is used for freeing up allocated memory.

What causes out of memory errors?

An "Out of Memory" error can occur when a Database Node Memory (KB) becomes less than 2 percent of the target size, and it cannot discard database pages on the node anymore to get free pages.

What does error code out of memory mean?

"Out of memory" (OOM) is an error message seen when a computer no longer has any spare memory to allocate to programs. An out of memory error causes programs — or even the entire computer — to power down.


1 Answers

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.

like image 152
plaisthos Avatar answered Sep 29 '22 21:09

plaisthos