Heim  >  Fragen und Antworten  >  Hauptteil

c++ – So schreiben Sie Daten mit gcc an eine bestimmte Adresse im .text-Abschnitt

1. Jetzt muss ich einige Daten in eine bestimmte Adresse von .text (Codesegment) einfügen. Zum Beispiel {'a','b','c','d','e','f','g','g'}
用的代码是char sgy_data2[32] __attribute__((section(".mysection1"))) = {'a','b','c','d','e','f','g','g'};
Die Startadresse meines .text-Segments ist 0XFFFE8000, und dann möchte ich Daten bei 0XFFFE8400 schreiben (die Gesamtlänge von .text ist größer als 1024).
2. Wenn Sie E2 erfolgreich verwendet haben, können Sie mir sagen, wie man es einrichtet?

PHP中文网PHP中文网2660 Tage vor975

Antworte allen(1)Ich werde antworten

  • 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 官方的解释)
    如果你不增加keep选项的话,不管你如何定义变量,都应该“用”一下这个变量,不然编译器会忽略这个变量,并且不会往bin文件中写入你想要的数据。
    至于其他的情况类似。

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

    Antwort
    0
  • StornierenAntwort