Issue 133684
Summary [x86] why llvm keep rodata.const section when compile with -fdata-sections
Labels new issue
Assignees
Reporter LukeSTM
    https://godbolt.org/z/r8ha9o9nf

```
#include <stdio.h>
#include <string.h> 
 
struct ss_t {
	int s_id;
	char msg[];
};

struct ss_t *mst_1;

void do_some_test(void)
{
	struct ss_t *mst_2;
	char buf[100];
	int fill_num=4;
	char tmp_str[40]="test stringssssssssss!";
	memcpy(buf,&fill_num,sizeof(int));
	memcpy(buf+sizeof(int), tmp_str, strlen(tmp_str) + 1); 
	mst_1=(struct ss_t *)buf;
 
	if (mst_1->s_id==4)
		printf("mst_1->s_id=%d,mst_1->msg=%s\n",mst_1->s_id,mst_1->msg);
}
```

![Image](https://github.com/user-attachments/assets/ffdba4a7-1a04-440d-98d2-1e21a974e239)

sorry, but i want know, why clang keep .rodata..L__const.do_some_test.tmp_str in sections. Constant could be expanded into movabsq instructions, and what would use .rodata..L__const.do_some_test.tmp_str? Dose it should be removed ?

![Image](https://github.com/user-attachments/assets/50fd1a2c-b4f0-4bb3-8d19-7807b8a83c2a)

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to