Le Sat, 17 Dec 2011 13:26:02 -0500,
Boris Gjenero <boris.gjenero_at_gmail.com> a écrit :
> It seems there's interest in automatically removing unused code via
> --gc-sections. Theoretically, the requirements are easy:
> --gc-sections requires KEEP() in linker scripts around things that need
> to be kept but are not directly referenced. This only seems to affect
> vectors, because they're only accessed by the CPU.
> -ffunction-sections requires wildcards for .text, because it puts
> functions in sections like ".text.functionname".
> -fdata-sections similarly requires wildcards for .data, .rodata and
> .bss. I don't see a benefit from -fdata-sections due to very little
> removed data and added alignment padding. However, I think adding what's
> required to allow it to work is a good idea because it's simple.
I think jhMikeS already did that part in r31337 (wow, how come we
missed that revision?)
> Here's a patch which does all that:
> http://www.rockbox.org/tracker/task/12378?getfile=24520 . I'm not
> certain that it's wise to touch linker scripts that aren't used for
> regular target and bootloader builds, but KEEP() shouldn't cause any
> harm. I only added wildcards to firmware/rom.lds, because only that is
> required to make this work with normal builds.
Looks straightforward to me, I think you should just commit it
> When something is explicitly put into a particular section, it won't be
> automatically moved into a subsection. For example, this includes things
> put into .icode via ICODE_ATTR. Such things will only be removed if
> nothing else in the same section in the same object file is referenced.
> Wildcards for such sections aren't required unless something has been
> explicitly moved into a sub-section. Maybe it's a good idea to use
> something like ICODE_ATTR("functionname") in the future? I could add
> wildcards for that if desired.
Yep i think it sounds cool
> Builds using these switches shouldn't significantly increase load for
> the build infrastructure. However, when the switches are first enabled,
> all object files should be re-created to ensure they all use
> I don't have a patch to add -ffunction-sections to GCCOPTS and
> -Wl,--gc-sections to GLOBAL_LDOPTS because I'm not sure how they should
> be added. My results at
> imply that it should work for all those targets. However, it may be
> better to be cautious and only enable it for selected tested targets.
> I think the linker scripts could use some cleanup and merging. I didn't
> get around to that, and I don't think making these changes will make
> future cleanup and merging harder.
Yeah I think they are separate changes but indeed a linker template
would be cool and avoid copy/pasted stuff
Received on 2011-12-17