Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit 8e983a3

Browse files
aswatermanpalmer-dabbelt
authored andcommitted
Emit small read-only data into .srodata section
1 parent f3fb5bd commit 8e983a3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

gcc/config/riscv/riscv.c

+22
Original file line numberDiff line numberDiff line change
@@ -2857,6 +2857,22 @@ riscv_in_small_data_p (const_tree x)
28572857
return riscv_size_ok_for_small_data_p (int_size_in_bytes (TREE_TYPE (x)));
28582858
}
28592859

2860+
/* Switch to the appropriate section for output of DECL. */
2861+
2862+
static section *
2863+
riscv_select_section (tree decl, int reloc,
2864+
unsigned HOST_WIDE_INT align)
2865+
{
2866+
switch (categorize_decl_for_section (decl, reloc))
2867+
{
2868+
case SECCAT_SRODATA:
2869+
return get_named_section (decl, ".srodata", reloc);
2870+
2871+
default:
2872+
return default_elf_select_section (decl, reloc, align);
2873+
}
2874+
}
2875+
28602876
/* Return a section for X, handling small data. */
28612877

28622878
static section *
@@ -4154,6 +4170,12 @@ riscv_constant_alignment (const_tree exp, HOST_WIDE_INT align)
41544170
#undef TARGET_IN_SMALL_DATA_P
41554171
#define TARGET_IN_SMALL_DATA_P riscv_in_small_data_p
41564172

4173+
#undef TARGET_HAVE_SRODATA_SECTION
4174+
#define TARGET_HAVE_SRODATA_SECTION true
4175+
4176+
#undef TARGET_ASM_SELECT_SECTION
4177+
#define TARGET_ASM_SELECT_SECTION riscv_select_section
4178+
41574179
#undef TARGET_ASM_SELECT_RTX_SECTION
41584180
#define TARGET_ASM_SELECT_RTX_SECTION riscv_elf_select_rtx_section
41594181

0 commit comments

Comments
 (0)