Home  >  Q&A  >  body text

c++ - How to write data at a specific address in the .text section using gcc

1. Now I need to insert some data into a certain address of .text (code segment). For example, {'a','b','c','d','e','f','g','g'}, the code used for
is char sgy_data2[32] __attribute__((section(".mysection1"))) = {'a','b','c','d','e','f','g','g'};
The starting address of my .text segment is 0XFFFE8000, and then I want to write data at 0XFFFE8400 (the total length of .text is greater than 1024). What should I do?
2. If you have used E2 successfully, can you tell me how to set it up?

PHP中文网PHP中文网2660 days ago972

reply all(1)I'll reply

  • phpcn_u1582

    phpcn_u15822017-06-10 09:50:37

    For E2:In order to have your data populated into your sections, you should take some additional steps. After adding the section, right click on it and add the following two expressions:
    .section-name
    .section-name.*
    (GNU official explanation)
    If you do not add the keep option, no matter how you define the variable, you should "use" this variable, otherwise the compiler will ignore this variable and will not write what you want to the bin file. required data.
    As for other situations, it is similar.

    .text 0xFFE00000 : AT (0xFFE00000)
        {
            *(.text)
            *(.text.*)
            *(P)
            etext = .;
        } > ROM
        
        相对应的你的gsi文件应该是这么样的

    reply
    0
  • Cancelreply