Defining a fixed-address section in a linker script for a static-pie binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there a way to compile/link a `static-pie` binary with a linker
script where *some* sections (NOLOAD ones) should be always located in
the same position, regardless of where the binary is being loaded to?
To put in a perspective, I write a bare-metal firmware (for risc-v if
it matters) which should be PIE. However it has certain memory regions
that are "special". Think like shared memory with other processors. So
for position-dependent FW I'd do something like this:


    __attribute__((section(".special_section")))
    volatile uint8_t shared_mem[100];


and in the linker script:

    SECTIONS {
    .....
        .special_section 0x12340000 (NOLOAD): {
            *(.special_section)
        }
    .....
    }
---
However this does not work with static-pie. The accesses to shared_mem
which are generated by the compiler are relative to the address the
binary is loaded to (well.. as expected) and not to the absolute
`0x12340000` address. Is such a use case even supported? What is the
proper way to achieve this?



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux