Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22298

Linker script to add tables to rodata segment

$
0
0

I'm trying to port some code that builds up tables at compile time. I don't want to maintain a stand alone linking script for this. I just want to add a few things to all the magic that the compiler is already doing for linking.

At compile time, entries for the table are marked with a specially named section. Then some linker commands (see below) assemble everything with that name into a table with symbols for the start and end. This is similar to how C++ does static initializers, but in user level code.

I'm using clang at the moment, but I understand it to be the same as gcc for this.

This mini linking script is almost the right thing, but how do I tell the linker that this section should be included in rodata?

SECTIONS {    _bt_channels_area : SUBALIGN(4)    {            _bt_l2cap_fixed_chan_list_start = .;            KEEP(*(SORT("._bt_l2cap_fixed_chan.static.*")))            _bt_l2cap_fixed_chan_list_end = .;    }}

Viewing all articles
Browse latest Browse all 22298

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>