9.6.7.6 Keep Built-in Function
The KEEP(section)
built-in function can
be used to prevent a section from being eliminated as part of link-time garbage collection
(--gc-sections
). This is accomplished by surrounding
an input section's wildcard entry with KEEP()
, as in
KEEP(*(.init))
or KEEP(SORT_BY_NAME(*)(.ctors))
.