Skip to content

Add (default on) --as-needed-gc flag to remove DSOs used only by GC'ed sections#1617

Closed
agrieve wants to merge 1 commit into
rui314:mainfrom
agrieve:as-needed-gc
Closed

Add (default on) --as-needed-gc flag to remove DSOs used only by GC'ed sections#1617
agrieve wants to merge 1 commit into
rui314:mainfrom
agrieve:as-needed-gc

Conversation

@agrieve

@agrieve agrieve commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

lld does this by default. bfd and gold do not. See: https://crbug.com/529102889

This flag makes mold behave like lld when both --as-needed and --gc-sections are used. If a DSO is only referenced by sections that are garbage-collected, the DSO's DT_NEEDED entry will be omitted.

@agrieve

agrieve commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Note #1618 is the same but without a flag (I'm leaning towards that being better, but thought I'd leave it up to you)

…d sections

lld does this by default. See: https://crbug.com/529102889

This flag makes mold behave like lld when both --as-needed and
--gc-sections are used. If a DSO is only referenced by sections that are
garbage-collected, the DSO's DT_NEEDED entry will be omitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants