How to refer to the start-of a user-defined segment in a Visual Studio-project?

后端 未结 2 1660
轮回少年
轮回少年 2021-01-02 15:30

I\'m struggling to convert a C-program linked with ld, of the gnu tool-chain to make it compile as a visual-studio (2005) project. The program puts .data-symbols in differe

相关标签:
2条回答
  • 2021-01-02 15:56

    Create additional segments (they are placed in memory alphabetically):

    #pragma data_seg("MY_DATA_FOO__a")
    #pragma data_seg("MY_DATA_FOO__z")
    #pragma data_seg("MY_DATA_FOO__m")
    
    __declspec(allocate("MY_DATA_FOO__a")) int fooFirst;
    __declspec(allocate("MY_DATA_FOO__z")) int fooLast;
    __declspec(allocate("MY_DATA_FOO__m")) int foo1;
    __declspec(allocate("MY_DATA_FOO__m")) int foo2;
    

    Then copy everything between &fooFirst and &fooLast.

    0 讨论(0)
  • 2021-01-02 16:00

    padding can be removed by segments merging

    for example

    #pragma data_seg(".foo_begin")
    #pragma data_seg(".foo_data")
    #pragma data_seg(".foo_end")
    
    #pragma comment( linker, "/merge:.foo_begin=.foo" )
    #pragma comment( linker, "/merge:.foo_data=.foo" )
    #pragma comment( linker, "/merge:.foo_end=.foo" )
    
    __declspec(allocate(".foo_begin")) int foo_begin_marker;
    __declspec(allocate(".foo_end")) int foo_end_marker;
    
    __declspec(allocate(".foo_data")) int foo_data;
    
    0 讨论(0)
提交回复
热议问题