Howto pass commands to the linker script via .pro file



  • I'm using Qt 5.3.2 with GCC 4.8.2. I have legacy C code in my project which I cannot change. But I need to reset its variables in order to reset the whole legacy codes state. But most of the variables are static and dont have functions to access them for resetting. Therefore I want to map the legacy codes variables to a defined section via the linker script, read them when starting my program and if needed write them back in order to reset this part of the program.

    What my linker script should look like to achieve this is something like this:

    SECTIONS
    {
      .legacy_vars :
      {
        *legacyModule.o (.bss)
        *legacyModule.o (.data)
        *legacyModule.o (COMMON)
      }
      .everything_else :
      {
        * (.bss)
        * (.data)
        * (COMMON)
        * (.text)
      }
    

    }

    I have already tried to pass this linker script with the value "QMAKE_LFLAGS" using "-T myscript.ldf" and just "myscript.ldf". But both ways result in errors since:

    1. qmake is creating an own linker script called "object_script" which defines the input files for the linkage.
    2. If I'm removing the object_script from the linkage no input files are being defined -> my project gets compiled but nothing is linked since no files are defined.
    3. If I'm adding the input files in my script with INPUT(...) it results in not linking with the error: "crt0_c.c:-1: Fehler: undefined reference to `WinMain@16'" "File not found: crt0_c.c" which is not a file of my project

    Is there a way i can achieve what I want?
    Thanks in advance!



  • Found a solution and posted it on stackoverflow:

    solution


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.