Skip to content

fix(bthread/context): Add .previous after GNU-stack note for aarch64#3266

Merged
chenBright merged 1 commit into
apache:masterfrom
condy0919:fix-asan-build
Apr 20, 2026
Merged

fix(bthread/context): Add .previous after GNU-stack note for aarch64#3266
chenBright merged 1 commit into
apache:masterfrom
condy0919:fix-asan-build

Conversation

@condy0919

Copy link
Copy Markdown
Contributor

Add missing .previous directive after each .note.GNU-stack section in ARM inline assembly blocks. This ensures proper section switching and prevents potential assembler errors when building with asan.

What problem does this PR solve?

Issue Number: resolve #1186

Problem Summary:

When build brpc with asan enabled, gcc complains something similar with the following line

`.note.GNU-stack' referenced in section `.init_array.00099' of ../../output/lib/libbrpc.a(context.cpp.o): defined in discarded section

Add missing .previous directive after each .note.GNU-stack section in ARM inline
assembly blocks. This ensures proper section switching and prevents potential
assembler errors when building with asan.

See apache#1186
@condy0919 condy0919 changed the title fix(bthread/context): Add .previous after GNU-stack note fix(bthread/context): Add .previous after GNU-stack note for aarch64 Apr 9, 2026
@wwbmmm wwbmmm requested a review from Copilot April 10, 2026 01:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes ARM inline-assembly section switching in bthread/context.cpp by adding a missing .previous directive after emitting the .note.GNU-stack section, preventing the assembler from remaining in the discarded .note.GNU-stack section (which can surface as link/ASAN build errors).

Changes:

  • Add .previous after .section .note.GNU-stack,"",%progbits in the Linux ARM32 bthread_jump_fcontext and bthread_make_fcontext asm blocks.
  • Add .previous after .section .note.GNU-stack,"",%progbits in the Linux ARM64 bthread_jump_fcontext and bthread_make_fcontext asm blocks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@condy0919

Copy link
Copy Markdown
Contributor Author

@wwbmmm ping. I thought it could be merged.

@wwbmmm

wwbmmm commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

LGTM

@chenBright chenBright left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@chenBright chenBright merged commit 12a76ad into apache:master Apr 20, 2026
21 checks passed
zchuango pushed a commit to zchuango/brpc that referenced this pull request May 9, 2026
Add missing .previous directive after each .note.GNU-stack section in ARM inline
assembly blocks. This ensures proper section switching and prevents potential
assembler errors when building with asan.

See apache#1186
@condy0919 condy0919 deleted the fix-asan-build branch May 9, 2026 11:59
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.

编译ASAN版本报错

4 participants