helpGNU Libtool - Support: sr #108559, libtool binary wrappers fall prey...


sr #108559: libtool binary wrappers fall prey to aggressive optimizations

Submitter:  -Deleted Account- <lrn>
Submitted:  Fri 02 May 2014 05:16:44 AM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Sun 15 Mar 2015 04:28:01 PM UTC, comment #4: 

Care to close this bug?

-Deleted Account- <lrn>
Fri 02 May 2014 01:01:00 PM UTC, comment #3: 

I have now pushed this change, thanks for testing!


Peter Rosin <pekberg>
Project Member
Fri 02 May 2014 12:23:37 PM UTC, comment #2: 

Yeah, that worked

-Deleted Account- <lrn>
Fri 02 May 2014 09:09:34 AM UTC, comment #1: 

Isn't this a more direct approach, not affected by new and even
more aggressive optimizations?

-volatile const char * MAGIC_EXE = "$magic_exe";
+#if _GNUC_ < 4 || (_GNUC_ == 4 && _GNUC_MINOR_ < 5)
+# define externally_visible volatile
+# define externally_visible _attribute_((externally_visible)) volatile
+externally_visible const char * MAGIC_EXE = "$magic_exe";

Does the above work for you?


Peter Rosin <pekberg>
Project Member
Fri 02 May 2014 05:16:44 AM UTC, original submission:  

When building binary wrappers (say, for W32), libtool puts a MAGIC constant string into them. Later on libtool greps the program for this string to see whether this is a wrapper or a real program.

However, MAGIC string is not used in the program in any way, and gcc may remove it. This does happen when building with -flto.

My proposal would be to make use of the string somehow to fool gcc into leaving it alone. For example, this call:

           lt_fatal (_FILE_, _LINE_,
    "unrecognized %s option: '%s'",
                    ltwrapper_option_prefix, argv[i]);

can be changed like this:

           lt_fatal (_FILE_, _LINE_,
    "unrecognized %s option: '%s'\0%s",
                    ltwrapper_option_prefix, argv[i], MAGIC_EXE);

-Deleted Account- <lrn>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by pekberg (Posted a comment)
  • -email is unavailable- added by lrn (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-05-02 pekberg StatusNone Done

    Back to the top

    Powered by Savane 3.9