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

how to access linker symbol in c code with MinGW?

$
0
0

I am using Mingw gcc and ld to generate an executable for windows. I would like to access the start address of a section in c code, but I have tried a lot of methods and no one works.

My linker script file has this:

  .data BLOCK(__section_alignment__) :
  {
    __data_start__ = . ;
    *(.data)
    *(.data2)
    *(SORT(.data$*))
    KEEP(*(.jcr))
    __data_end__ = . ;
    *(.data_cygwin_nocopy)
  }

In C code I do this:

extern char  __data_start__;
uint32_t  test = &__data_start__;

And get this error: undefined reference to `data_start'

Could anyone help me with this? Thanks


Viewing all articles
Browse latest Browse all 22130

Trending Articles



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