Bug 32082

Summary: gas arm aarch64: missing mapping symbols $d in the absence of alignment directives
Product: binutils Reporter: Fangrui Song <i>
Component: gasAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: renlin.dev, sam
Priority: P2    
Version: unspecified   
Target Milestone: ---   
See Also: https://reviews.llvm.org/D30724
Host: Target: arm*-*-* aarch64-*-*
Build: Last reconfirmed:

Description Fangrui Song 2024-08-14 06:11:29 UTC
Data sections without alignment directives (excluding
BSS) might lack '$d' symbols, and mixing data and text sections can
introduce state transition problems.

The relevant code was modified by 
https://sourceware.org/pipermail/binutils/2015-March/088214.html 


% cat x.c
char var = 1;
char arr[2] = {1};
% arm-linux-gnueabi-gcc -c -fdata-sections x.c && objdump -t x.o  #
aarch64-linux-gnu-gcc is similar

x.o:     file format elf32-little

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 x.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .data.var      00000000 .data.var
00000000 l    d  .data.arr      00000000 .data.arr
00000000 l       .data.arr      00000000 $d
...

LLVM integrated assembler's AArch32 port doesn't insert '$d' unless
code is present, which could lead to similar issues.
(https://reviews.llvm.org/D30724)

% clang -c --target=armv7-linux-gnueabi -fdata-sections x.c && objdump -t x.o

x.o:     file format elf32-little

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 x.c
00000000 g     O .data.var      00000001 var
00000000 g     O .data.arr      00000002 arr