Skip to content
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

clang: -fno-pie should not imply -fdirect-access-external-data for loongarch*-linux #71645

Closed
xry111 opened this issue Nov 8, 2023 · 4 comments · Fixed by #72221
Closed

clang: -fno-pie should not imply -fdirect-access-external-data for loongarch*-linux #71645

xry111 opened this issue Nov 8, 2023 · 4 comments · Fixed by #72221
Assignees
Labels
backend:loongarch clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@xry111
Copy link
Contributor

xry111 commented Nov 8, 2023

loongarch*-linux does not and will not support copy relocation, so -fdirect-access-external-data generally does not work for any dynamic-linked executable.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 8, 2023
@xry111
Copy link
Contributor Author

xry111 commented Nov 8, 2023

xry111@nanmen2 ~ $ cat t1.c
extern char **environ;

int main()
{
  __builtin_printf("%10s\n", environ[0]);
}
xry111@nanmen2 ~ $ clang t1.c -fdirect-access-external-data -O2
xry111@nanmen2 ~ $ ./a.out 
Bus error (core dumped)

@xry111
Copy link
Contributor Author

xry111 commented Nov 8, 2023

@xen0n @SixWeining

@EugeneZelenko EugeneZelenko added clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' backend:loongarch and removed clang Clang issues not falling into any other category labels Nov 8, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 8, 2023

@llvm/issue-subscribers-clang-driver

Author: Xi Ruoyao (xry111)

loongarch*-linux does not and will not support copy relocation, so -fdirect-access-external-data generally does not work for any dynamic-linked executable.

@SixWeining
Copy link
Contributor

SixWeining commented Nov 9, 2023

add @wangleiat

@heiher heiher self-assigned this Nov 10, 2023
heiher added a commit to heiher/llvm-project that referenced this issue Nov 10, 2023
LoongArch does not and will not support copy relocation, so non-PIC code
defaults to -fno-direct-access-external-data.

Explicit `-fdirect-access-external-data` is acceptable, for example if
the code is writable.

Reported-by: Xi Ruoyao <[email protected]>
Signed-off-by: WANG Rui <[email protected]>

Fixes llvm#71645
MaskRay added a commit to MaskRay/llvm-project that referenced this issue Nov 14, 2023
…n-PIC

For -fno-pic, if an extern variable is defined in a DSO, a copy
relocation will be needed. However, loongarch*-linux does not and will
not support copy relocations.

Change Driver to default to -fno-direct-access-external-data for
LoongArch && non-PIC.
Keep Frontend conditions unchanged (-fdirect-access-external-data ||
-fno-direct-access-external-data && PIC>0 => direct access).

Fix llvm#71645
MaskRay added a commit that referenced this issue Nov 14, 2023
…n-PIC (#72221)

For -fno-pic, if an extern variable is defined in a DSO, a copy
relocation will be needed. However, loongarch*-linux does not and will
not support copy relocations.

Change Driver to default to -fno-direct-access-external-data for
LoongArch && non-PIC.
Keep Frontend conditions unchanged (-fdirect-access-external-data ||
-fno-direct-access-external-data && PIC>0 => direct access).

Fix #71645
zahiraam pushed a commit to zahiraam/llvm-project that referenced this issue Nov 20, 2023
…n-PIC (llvm#72221)

For -fno-pic, if an extern variable is defined in a DSO, a copy
relocation will be needed. However, loongarch*-linux does not and will
not support copy relocations.

Change Driver to default to -fno-direct-access-external-data for
LoongArch && non-PIC.
Keep Frontend conditions unchanged (-fdirect-access-external-data ||
-fno-direct-access-external-data && PIC>0 => direct access).

Fix llvm#71645
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:loongarch clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
5 participants