|
|
Subscribe / Log in / New account

Randomizing structure layout

Randomizing structure layout

Posted May 12, 2017 4:37 UTC (Fri) by k8to (guest, #15413)
Parent article: Randomizing structure layout

I'm sure this will be a joy to debug on.


to post comments

Randomizing structure layout

Posted May 12, 2017 12:41 UTC (Fri) by nix (subscriber, #2304) [Link] (3 responses)

It should be fine, I think -- the debuginfo GCC emits will contain appropriate offsets for all structure members post-randomization. (And debugging without debuginfo will remain precisely as painful as it always was.)

Randomizing structure layout

Posted May 14, 2017 23:49 UTC (Sun) by jreiser (subscriber, #11027) [Link] (2 responses)

debugging without debuginfo will remain precisely as painful as it always was.   No, it will be harder. The mapping from source declaration to binary layout previously could be understood quickly; now it will require reverse engineering (inspecting machine instructions for offsets from pointers), and it may change from version to version.

Randomizing structure layout

Posted May 15, 2017 21:47 UTC (Mon) by autious (guest, #114303) [Link] (1 responses)

Which is kinda the goal I think?

Randomizing structure layout

Posted May 17, 2017 12:45 UTC (Wed) by nix (subscriber, #2304) [Link]

Quite. The point is that if you ask gdb or crash or something else with access to the DWARF for info on some structure member's contents, it'll still be able to tell you what they are, exactly as it always could.

Randomizing structure layout

Posted May 12, 2017 13:03 UTC (Fri) by abradona (subscriber, #96602) [Link]

that's what I was thinking about too ;-)

Randomizing structure layout

Posted May 14, 2017 17:49 UTC (Sun) by johan (guest, #112044) [Link] (1 responses)

"The randstruct plugin is a new GCC add-on that lets the compiler randomize the layout of C structures."

Since it's a plugin I'm hoping that it has sane defaults so the randstruct plugin is disabled when specifying -g

Randomizing structure layout

Posted May 17, 2017 12:44 UTC (Wed) by nix (subscriber, #2304) [Link]

Well, if it were built in to GCC and not a plugin this would actually be considered unacceptable: specifying -g should not change the generated code in any way (including disabling, say, structure randomization). What should happen, instead (and what I think does in fact happen) is that the generated debugging info correctly represents the structures' randomized field offsets in the DWARF. (DWARF does not require structure members to be represented in ascending order: indeed, they can be entirely overlapping -- this is how unions are represented -- or even partially overlapping, reversed, or, as here, in random order.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds