6

I'd like to create a program with a special section at the end of Virtual Memory. So I wanted to do a linker script something like this:

 /* ... */
 .section_x 0xffff0000 : {
     _start_section_x = .;
     . = . + 0xffff;
     _end_section_x = .;
 }

The problem is that gcc/ld/glibc seem to load the stack at this location by default for a 32 bit application, even if it overlaps a known section. The above code zero's out the stack causing an exception. Is there any way to tell the linker to use another VM memory location for the stack? (As well, I'd like to ensure the heap doesn't span this section of virtual memory...).

HardcoreHenry
  • 3,775
  • 2
  • 11
  • 33
  • You need to provide more information about your target. The initial register contents (which determines the stack location) is target-dependent. – Florian Weimer Nov 21 '17 at 19:26
  • This is an arm-8 system (compiling in 32 bit mode). I am using a linux 3.10 kernel with a gcc 4.7.0 toolchain. – HardcoreHenry Nov 21 '17 at 19:56

1 Answers1

1

I hate answers that presume or even ask if the question is wrong but, if you need a 64k segment, why can't you just allocate one on startup?

Why could you possibly need a fixed address within your process address space? I've been doing a lot of different kinds of coding for almost 30 years, and I haven't seen the need for a fixed address since the advent of protected memory.

Eliot Gillum
  • 683
  • 7
  • 17
  • No unfortunately the question is not incorrect. I'm modifying an existing system with the capability to assign special meaning to various bits in a pointer. As such, I need to reserve the 0xffff0000 address range for a special purpose. – HardcoreHenry Nov 27 '17 at 15:06
  • @HardcoreHenry I'm sure whoever created this system described it as "elegant" however I think 99% of the world, hopefully including you, sees this as evil. That said, why do these goofy pointers have to resolve to valid addresses? Can't some layer of abstraction provide the additional functionality while not requiring fixed memory addresses? They could point to a struct with those bits set, or dereferencing the pointer could be done by a routine which knows how to do a lookaside? – Eliot Gillum Nov 28 '17 at 17:29