Fix for unlikely text section grouping in conjunction with gcc's -ffunction-sections

Jeff Law law@redhat.com
Fri Jul 5 20:05:00 GMT 2013


Normally when GCC wants to emit an unlikely to be executed function, 
it'll put it in the .text.unlikely section.


However, when -ffunction-sections is enabled, the function will be 
placed into the .text.unlikely.<funcname> section.  Thus 
.text.unlikely.* sections need to be handled in the ELF linker script.

At some point in the past, GCC used something like .text.name_unlikely, 
which was a horrible choice.  I chose to keep that old style since we 
might be linking older objects with the older style name.

Note I didn't want to use .text.unlikely* as that would unfortunately 
match a function named "unlikely" when -ffunction-sections is active.

OK to install?


-------------- next part --------------
	* scripttempl/elf.sc: Handle function names and other
	text after .text.unlikely too.



diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 318e054..e8126cb 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -470,7 +470,7 @@ cat <<EOF
   .text         ${RELOCATING-0} :
   {
     ${RELOCATING+${TEXT_START_SYMBOLS}}
-    ${RELOCATING+*(.text.unlikely .text.*_unlikely)}
+    ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)}
     ${RELOCATING+*(.text.exit .text.exit.*)}
     ${RELOCATING+*(.text.startup .text.startup.*)}
     ${RELOCATING+*(.text.hot .text.hot.*)}


More information about the Binutils mailing list