简体   繁体   中英

What is the difference between .rodata and .rdata

I've seen both .rodata and .rdata being used as segments. Which one should I use and what are the differences between them?

RODATA is used in ELF and RDATA is used inCOFF . The closest equivalent in Mach-O would be __TEXT,__const .

What is the difference between.rodata and.rdata

The main (only?) difference is cultural.

For linkers and loaders (and object file formats), you can use whatever name you like. It doesn't matter as long as (during linking) things that should be in the same section use the same name for that section, and the properties of that section are adequately described (eg using a linker script, including the default linker script for the OS). There also isn't anything preventing you from having multiple separate sections (eg maybe "rdata_initialization", "rdata_frequently_used" and "rdata_rarely_used" to improve cache locality) if you're willing to deal with the extra hassle.

However, for convenience (given that most people don't do anything special with sections), to ensure tools use the same name for the same section compilers use whatever is "normal" for a certain OS as the default, and will assume ".rdata" for Windows (because that's normal for Windows) and "rodata" for *nix clones (because that's normal for Unix).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM