Skip to content

[LLD][Docs] Document -z gcs= option in the man page #146522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sivan-shani
Copy link
Contributor

@sivan-shani sivan-shani commented Jul 1, 2025

Add documentation for the -z gcs= option to the LLD man page. This flag controls how the GCS bit is set in the output:

  • implicit (default): inferred from input objects
  • never: GCS bit is never set
  • always: GCS bit is always set

Clarifies behavior for users and aligns the man page with existing functionality.

Add documentation for the `-z gcs` option to the LLD man page. This flag controls how the GCS bit is set in the output:

- implicit (default): inferred from input objects
- never: GCS bit is never set
- always: GCS bit is always set

Clarifies behavior for users and aligns the man page with existing functionality.
Add documentation for the -z gcs= option to the LLD man page. This flag controls how the GCS bit is set in the output:

- implicit (default): inferred from input objects
- never: GCS bit is never set
- always: GCS bit is always set

Clarifies behavior for users and aligns the man page with existing functionality.
@@ -953,6 +958,15 @@ disallows overlap.
.It Cm shstk
x86 only, use shadow stack.
.Pp
.It Cm gcs Ns = Ns Ar [implicit|never|always]
Specify how the GCS bit is set. A set GCS bit indicates that the object file supports the Guarded Control Stack security feature.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to say

Specify how the GNU_PROPERTY_AARCH64_FEATURE_1_GCS feature bit is set in the output ELF file. When set this declares that the ELF file supports the Guarded Control Stack (GCS) security feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, wording improved

.It Cm gcs Ns = Ns Ar [implicit|never|always]
Specify how the GCS bit is set. A set GCS bit indicates that the object file supports the Guarded Control Stack security feature.
.Cm implicit
is the default, where the GCS bit is inferred from the input objects.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From looking at noseparate-code above. I suggest
(default) feature bit is inferred from the input object marking.

I've suggested feature bit rather than GCS bit as we've used the full GNU_PROPERTY_AARCH64_FEATURE_1_GCS feature bit above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, wording improved

.Cm implicit
is the default, where the GCS bit is inferred from the input objects.
.Cm never
disables the GCS bit regardless of input markings.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest
clears the feature bit regardless of input object marking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, wording improved

@sivan-shani
Copy link
Contributor Author

Comments handled

Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there. I think if we can use the same wording as on bti-report and cet-report then we're good.

.It Cm gcs-report Ns = Ns Ar [none|warning|error]
Specify how to report missing GNU_PROPERTY_AARCH64_FEATURE_1_GCS property. GNU_PROPERTY_AARCH64_FEATURE_1_GCS indicates object file support for the Guarded Control Stack security feature.
.Cm none
is the (default) linker will not report the missing property otherwise, missing property will be reported as a warning or an error.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for being a pain. A couple of nits on this line:

I meant (default) at the start of the line. However, looking at bti-report and cet-report above it is probably better to follow the convention and use "is the default," . It was probably that originally; sorry for the noise.

The comma after otherwise looks to be in the wrong position [1]. I think we should follow the wording of bit-report and cet-report.

is the default, linker will not report the missing property otherwise will be reported as a warning or an error.

[1] If I were rewriting with a comma I'd say "report the missing propery, otherwise it will be reported as a warning or an error." However best to stay consistent with the existing wording.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, also for gcs using (default)

@sivan-shani
Copy link
Contributor Author

Comments handled (indicating default option and alignment with other report options)

Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the updates. Please leave a few days before merging to give @MaskRay a chance to comment.

@sivan-shani sivan-shani marked this pull request as ready for review July 2, 2025 14:34
@llvmbot llvmbot added the lld label Jul 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2025

@llvm/pr-subscribers-lld

Author: SivanShani-Arm (sivan-shani)

Changes

Add documentation for the -z gcs= option to the LLD man page. This flag controls how the GCS bit is set in the output:

  • implicit (default): inferred from input objects
  • never: GCS bit is never set
  • always: GCS bit is always set

Clarifies behavior for users and aligns the man page with existing functionality.


Full diff: https://github.com/llvm/llvm-project/pull/146522.diff

1 Files Affected:

  • (modified) lld/docs/ld.lld.1 (+14)
diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1
index 7edc522b4f6a4..49efc1269e7f2 100644
--- a/lld/docs/ld.lld.1
+++ b/lld/docs/ld.lld.1
@@ -798,6 +798,11 @@ Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY
 .Cm none
 is the default, linker will not report the missing property otherwise will be reported as a warning or an error.
 .Pp
+.It Cm gcs-report Ns = Ns Ar [none|warning|error]
+Specify how to report missing GNU_PROPERTY_AARCH64_FEATURE_1_GCS property. GNU_PROPERTY_AARCH64_FEATURE_1_GCS indicates object file support for the Guarded Control Stack security feature.
+.Cm none
+is the default, linker will not report the missing property otherwise will be reported as a warning or an error.
+.Pp
 .It Cm dynamic-undefined-weak
 Make undefined weak symbols dynamic when the dynamic symbol table is present, if they are referenced from
 relocatable object files and not forced local by symbol visibility or versioning. Do not make them dynamic when
@@ -953,6 +958,15 @@ disallows overlap.
 .It Cm shstk
 x86 only, use shadow stack.
 .Pp
+.It Cm gcs Ns = Ns Ar [implicit|never|always]
+Specifies how the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit is set in the output ELF file. When set, it indicates support for the Guarded Control Stack (GCS) security feature.
+.Cm implicit
+(default) GCS feature bit is inferred from the input object marking.
+.Cm never
+clears the GCS feature bit regardless of input object markings.
+.Cm always
+set the GCS feature bit regardless of input object markings.
+.Pp
 .It Cm stack-size Ns = Ns Ar size
 Set the main thread's stack size to
 .Ar size .

@@ -798,6 +798,11 @@ Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY
.Cm none
is the default, linker will not report the missing property otherwise will be reported as a warning or an error.
.Pp
.It Cm gcs-report Ns = Ns Ar [none|warning|error]
Specify how to report missing GNU_PROPERTY_AARCH64_FEATURE_1_GCS property. GNU_PROPERTY_AARCH64_FEATURE_1_GCS indicates object file support for the Guarded Control Stack security feature.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU_PROPERTY_AARCH64_FEATURE_1_* properties need to use .Cm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, handled.

@@ -953,6 +958,15 @@ disallows overlap.
.It Cm shstk
x86 only, use shadow stack.
.Pp
.It Cm gcs Ns = Ns Ar [implicit|never|always]
Specifies how the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit is set in the output ELF file. When set, it indicates support for the Guarded Control Stack (GCS) security feature.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .Cm GNU_PROPERTY_AARCH64_FEATURE_1_GCS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, handled.

.It Cm gcs Ns = Ns Ar [implicit|never|always]
Specifies how the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit is set in the output ELF file. When set, it indicates support for the Guarded Control Stack (GCS) security feature.
.Cm implicit
(default) GCS feature bit is inferred from the input object marking.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input object marking is vague. I'd emphasize relocatable files. Perhaps something like

When all relocatable files contain a .note.gnu.property section containing the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit

Copy link
Contributor Author

@sivan-shani sivan-shani Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, handled.

@sivan-shani
Copy link
Contributor Author

Comments handled (Add .Cm, use 'relocatable files')

Copy link
Member

@DanielKristofKiss DanielKristofKiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's see what other reviewers says.

.Cm implicit
is the default, where the GCS bit is inferred from the input objects.
is the (default) GCS feature bit is inferred from the input object marking.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reads as "is the GCS feature bit is inferred... "

Suggested change
is the (default) GCS feature bit is inferred from the input object marking.
is the default. GCS feature bit is inferred from the input object marking.

Copy link
Contributor Author

@sivan-shani sivan-shani Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above is outdated, I believe that new version does not suffer from same ambiguity.

.Cm always
enables the GCS bit regardless of input markings.
set the GCS feature bit regardless of input object markings.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set the GCS feature bit regardless of input object markings.
sets the GCS feature bit regardless of input object markings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, changed set->sets

@@ -801,7 +801,7 @@ is the default, linker will not report the missing property otherwise will be re
.It Cm gcs-report Ns = Ns Ar [none|warning|error]
Specify how to report missing GNU_PROPERTY_AARCH64_FEATURE_1_GCS property. GNU_PROPERTY_AARCH64_FEATURE_1_GCS indicates object file support for the Guarded Control Stack security feature.
.Cm none
is the default, linker will not report the missing property otherwise will be reported as a warning or an error.
is the (default) linker will not report the missing property otherwise, missing property will be reported as a warning or an error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the comma the sentence is strange to me.

Copy link
Contributor Author

@sivan-shani sivan-shani Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we might want to keep the wording as is, same as it is for

bti-report
cet-report

Which are the same flag type and has the exact same wording.

.Cm GNU_PROPERTY_AARCH64_FEATURE_1_GCS
bit is set in the output ELF file. When set, it indicates support for the Guarded Control Stack (GCS) security feature.
.Cm implicit
(default) The GCS feature bit is set if all input relocatable files have a .note.gnu.property section containing the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.note.gnu.property also needs Cm

@sivan-shani
Copy link
Contributor Author

[Apologies, Will be away for 5 weeks, response will be delayed]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants