Skip to contentSkip to conversation

Avoid ld errors messages by marking sd_major noinline.

SCSI Ralf Baechle 1 participant 1 message Mar 4, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

Gcc may compile sd_major() using a jump table which it will put into .rodata. If also inline sd_major's function body into exit_sd() and CONFIG_BLK_DEV_SD has been set to y ld is going to discard exit_sd's code later at link time. It won't discard the jump table if was put into another section than .exit.data and so the remaining refernces to sd_major's function body will result in about 100 lines of non-fatal linker error messages. This is avoided by marking sd_major noinline.

Observed on MIPS with GCC 4.0.2 and 4.1.0 but not 3.4.5 and seems possible on other architectures such as i386.

drivers/scsi/sd.c +9 -1
index 9d98723..f1af700 100644
@@ -158,8 +158,16 @@ static struct scsi_driver sd_template = 
  * for major1, ... 
  * As we stay compatible with our numbering scheme, we can reuse 
  * the well-know SCSI majors 8, 65--71, 136--143.
+ *
+ * Gcc may compile sd_major() using a jump table which it will put into
+ * .rodata.  If also inline sd_major's function body into exit_sd() and
+ * CONFIG_BLK_DEV_SD has been set to y ld is going to discard exit_sd's
+ * code later at link time.  It won't discard the jump table if was put
+ * into another section than .exit.data and so the remaining refernces to
+ * sd_major's function body will result in about 100 lines of non-fatal
+ * linker error messages.  This is avoided by marking sd_major noinline.
  */
-static int sd_major(int major_idx)
+static noinline int sd_major(int major_idx)
 {
 	switch (major_idx) {
 	case 0: