Skip to content

Fixed linker array sentinel on GCC, and added a test.#27042

Draft
copybara-service[bot] wants to merge 1 commit intomainfrom
test_904021133
Draft

Fixed linker array sentinel on GCC, and added a test.#27042
copybara-service[bot] wants to merge 1 commit intomainfrom
test_904021133

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service Bot commented Apr 22, 2026

Fixed linker array sentinel on GCC, and added a test.

This change modifies the UPB_LINKARR_DECLARE macro to use inline assembly to create a weak anchor symbol within the linkarr section. This ensures that the __start_linkarr_ and __stop_linkarr_ symbols are always defined by the linker, even when no other objects are placed in that section. The previous sentinel mechanism was broken on GCC.

A new test, generated_registry_empty_test, is added to verify that the generated registry can be loaded successfully and is empty when no extensions are actually linked into the binary.

Also adds upb_exttable_size and upb_ExtensionRegistry_Size for testing purposes.

@copybara-service copybara-service Bot changed the title Internal change Fixed linker array sentinel on GCC, and added a test. Apr 22, 2026
This change modifies the `UPB_LINKARR_DECLARE` macro to use inline assembly to create a weak anchor symbol within the linkarr section. This ensures that the `__start_linkarr_` and `__stop_linkarr_` symbols are always defined by the linker, even when no other objects are placed in that section. The previous sentinel mechanism was broken on GCC.

A new test, generated_registry_empty_test, is added to verify that the generated registry can be loaded successfully and is empty when no extensions are actually linked into the binary.

Also adds `upb_exttable_size` and `upb_ExtensionRegistry_Size` for testing purposes.

PiperOrigin-RevId: 904021133
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.

1 participant