fix: add MIPS-specific compiler flag to avoid GOT overflow#1211
Merged
Conversation
reddevillg
reviewed
Jun 11, 2025
| # MIPS 处理器在设计上对 GOT的大小有严格的限制,在链接了大量的共享库时,GOT 可能会膨胀,导致 | ||
| # __cxa_begin_catch(或其他任何需要通过 GOT 访问的符号)超出了 16 位偏移量的可寻址范围。 使用-mxgot选项是解决 | ||
| # R_MIPS_CALL16 溢出最常用的方法。这个选项会告诉 GCC 为全局符号生成使用 32 位偏移量访问 GOT 的代码,从而解除 16 | ||
| # 位偏移量的限制。 |
| "${CMAKE_CXX_FLAGS} -mxgot" | ||
| CACHE STRING "C++ compiler flags" FORCE) | ||
|
|
||
| set(CMAKE_CXX_FLAGS_RELEASE |
Collaborator
There was a problem hiding this comment.
只需要设置 CMAKE_CXX_FLAGS 就够了
| set(CMAKE_CXX_FLAGS_RELEASE | ||
| "${CMAKE_CXX_FLAGS_RELEASE} -mxgot" | ||
| CACHE STRING "C++ compiler flags for Release build" FORCE) | ||
| set(CMAKE_CXX_FLAGS_DEBUG |
MIPS architecture and globally applies the `-mxgot` flag to compiler settings to address potential GOT overflow issues caused by the architecture's strict limitations on GOT size.
reddevillg
approved these changes
Jun 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MIPS architecture and globally applies the
-mxgotflag to compiler settings to address potential GOT overflow issues caused by the architecture's strict limitations on GOT size.