Bug 14761

Summary: commands using SET_PTR_TO_GLOBALS segfaults when compiled with clang 12.0.1
Product: Busybox Reporter: Thiner Logoer <logoerthiner1>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: .config file for reference; mostly defconfig with only tweaks in general config

Description Thiner Logoer 2022-04-17 18:06:46 UTC
Created attachment 9286 [details]
.config file for reference; mostly defconfig with only tweaks in general config

I compiled busybox using clang (12.0.1, default version on alpine 3.15 amd64, make CC=clang STRIP=llvm-strip) on aarch64 architecture, and then run it on aarch64 linux kernel. Some of commands segfaults directly:
```
~ $ busybox getty
Segmentation fault
~ $ busybox vi
Segmentation fault
~ $ busybox awk
Segmentation fault
~ $ busybox ed   
Segmentation fault
~ $ busybox diff
Segmentation fault
~ $ busybox netstat
Segmentation fault
~ $ busybox wget
Segmentation fault
~ $ busybox ftpd
Segmentation fault
~ $ busybox httpd
Segmentation fault
~ $ busybox ntpd
~ $ busybox arping
Segmentation fault
```

I suspect SET_PTR_TO_GLOBALS is the culprit, since many commands using SET_PTR_TO_GLOBALS does not work at all.

clang 12.0.1 may not respect "unconst" black magic in busybox.