Can't add the allocated section to elf file using inline assembly
drug
drug2004 at bk.ru
Tue Nov 5 09:49:35 UTC 2019
Using clang the following code:
```
__asm__ __volatile__ (
".ifndef _.stapsdt.base\n" \
".pushsection .stapsdt.base,\"aG\",\"progbits\", .stapsdt.base, comdat\n" \
".weak _.stapsdt.base\n" \
".hidden _.stapsdt.base\n" \
"_.stapsdt.base: .space 1\n" \
".size _.stapsdt.base,1\n" \
".popsection\n" \
".endif"
);
```
adds the allocated section to elf file:
```
$ clang source/sdt_expanded.c -ocsdt
$ readelf -x .stapsdt.base csdt
Hex dump of section '.stapsdt.base':
0x000aa442 00 .
```
I translated this code to ldc:
```
__asm (
.ifndef _.stapsdt.base
.pushsection .stapsdt.base,\"aG\",\"progbits\", .stapsdt.base, comdat
.weak _.stapsdt.base
.hidden _.stapsdt.base
_.stapsdt.base: .space 1
.size _.stapsdt.base,1
.popsection
.endif`, ""
);
```
but ldc (1.18) do not add the section without any error.
```
$ dub --compiler=ldc2
$ readelf -x .stapsdt.base usdt
readelf: Warning: Section '.stapsdt.base' was not dumped because it does
not exist!
```
If I make the section non allocated (removing `a` from \"aG\") then the
section is added.
```
$ readelf -x .stapsdt.base usdt
Hex dump of section '.stapsdt.base':
0x00000000 00 .
```
But this section needs to be allocated.
Is it a bug or I misuse something? Is there way to work around it?
More information about the digitalmars-d-ldc
mailing list