Issue 174685
Summary [clang] Differential behavior in rodate between clang and gcc
Labels clang
Assignees
Reporter hutoushayu
    
example:
`
#include <stdio.h>
void fun01(void)
{
  printf("###fun01###\n");
}

void fun02_1(void)
{
  printf("###fun02###\n");
}
void fun02_2(void)
{
 printf("###fun02###\n");
}

__attribute__((section(".sec03"),noinline))
void fun03(void)
{
 printf("###fun03###\n");
}

__attribute__((section(".text"),noinline))
void fun04(void)
{
 printf("###fun04###\n");
}

__attribute__((section(".text.sec05"),noinline))
void fun05(void)
{
 printf("###fun05###\n");
}

__attribute__((section(".sec06_1"),noinline))
void fun06_1(void)
{
 printf("###fun06###\n");
}
__attribute__((section(".sec06_1"),noinline))
void fun06_2(void)
{
 printf("###fun06###\n");
}

__attribute__((section(".text.sec07_1"),noinline))
void fun07_1(void)
{
 printf("###fun07###\n");
}
__attribute__((section(".text.sec07_2"),noinline))
void fun07_2(void)
{
  printf("###fun07###\n");
}
`
version of clang : llvm-20.1.3
version of gcc: gcc-14.3.0
compiler and read section headers:
$clang demo01.c -ffunction-sections -fdata-sections -O2 -c -o demo01-clang.o
$gcc demo01.c -ffunction-sections -fdata-sections -O2 -c -o demo01-gcc.o
$readelf -SW demo01-gcc.o demo01-clang.o

To compare these section headers,we'll see gcc has generated additional sections :
.rodata.fun01.str1
.rodata.fun02_1.str1
.rodata.sec05.str1
.rodata.sec07_1.str1

Strings in functions were placed in separate segments.
But clang do not.













_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to