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

Ubuntu x86-64: To Link buffer to memory section created in predefined address

$
0
0

I want to create a 4MB buffer allocated in a predefined section of linker script. Using ld --verbose I got the default linker script used by gcc. I want to add a section called .exchangeBuffer addresable by 32-bit (virtual addresses are up to 48-bit, but I want to allocate my section in an address lower thaN 0x0000_FFFF_FFFF).

So, I imagine my buffer should be declared like this:

#define FOUR_MEGABYTES (4*1024*1024)uint8_t __attribute__((section (".exchangeBuffer"))) exchange[FOUR_MEGABYTES];

But then default linker script, starts like this:

OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64","elf64-x86-64")OUTPUT_ARCH(i386:x86-64)ENTRY(_start)SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu"); SEARCH_DIR("=/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu64"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib");SECTIONS{  /* Read-only sections, merged into text segment: */  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;  .interp         : { *(.interp) }  .note.gnu.build-id : { *(.note.gnu.build-id) }  .hash           : { *(.hash) }  .gnu.hash       : { *(.gnu.hash) }  .dynsym         : { *(.dynsym) }  .dynstr         : { *(.dynstr) }  .gnu.version    : { *(.gnu.version) }  .gnu.version_d  : { *(.gnu.version_d) }  .gnu.version_r  : { *(.gnu.version_r) }  .rela.dyn       :    {/* The scripts continue until end.... */  _end = .; PROVIDE (end = .);  . = DATA_SEGMENT_END (.);  /* Stabs debugging sections.  */  .stab          0 : { *(.stab) }  .stabstr       0 : { *(.stabstr) }  .stab.excl     0 : { *(.stab.excl) }  .stab.exclstr  0 : { *(.stab.exclstr) }  .stab.index    0 : { *(.stab.index) }  .stab.indexstr 0 : { *(.stab.indexstr) }  .comment       0 : { *(.comment) }  /* DWARF debug sections.     Symbols in the DWARF debugging sections are relative to the beginning     of the section so we begin them at 0.  */  /* DWARF 1 */  .debug          0 : { *(.debug) }  .line           0 : { *(.line) }  /* GNU DWARF 1 extensions */  .debug_srcinfo  0 : { *(.debug_srcinfo) }  .debug_sfnames  0 : { *(.debug_sfnames) }  /* DWARF 1.1 and DWARF 2 */  .debug_aranges  0 : { *(.debug_aranges) }  .debug_pubnames 0 : { *(.debug_pubnames) }  /* DWARF 2 */  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }  .debug_abbrev   0 : { *(.debug_abbrev) }  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }  .debug_frame    0 : { *(.debug_frame) }  .debug_str      0 : { *(.debug_str) }  .debug_loc      0 : { *(.debug_loc) }  .debug_macinfo  0 : { *(.debug_macinfo) }  /* SGI/MIPS DWARF 2 extensions */  .debug_weaknames 0 : { *(.debug_weaknames) }  .debug_funcnames 0 : { *(.debug_funcnames) }  .debug_typenames 0 : { *(.debug_typenames) }  .debug_varnames  0 : { *(.debug_varnames) }  /* DWARF 3 */  .debug_pubtypes 0 : { *(.debug_pubtypes) }  .debug_ranges   0 : { *(.debug_ranges) }  /* DWARF Extension.  */  .debug_macro    0 : { *(.debug_macro) }  .debug_addr     0 : { *(.debug_addr) }  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }}

Where and how should I place my 4MB section?

Please, note that executable is running on a 64-bit Desktop Linux compiled with their native gcc. All available information regarding this topic I found is related with embedded systems and simpler linker scripts, 32-bit processors without virtual addressing.

Thanks,


Viewing all articles
Browse latest Browse all 22016

Trending Articles



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