Subject: SH3 ELF
To: None <port-sh3@netbsd.org>
From: Hiroyuki Bessho <bsh@grotto.iijnet.or.jp>
List: port-sh3
Date: 11/09/2000 04:16:24
Previously I wrote NetBSD/sh3's ELF support is incomplete. Here is my
proposal of fix.
sys/sys/cdefs_elf.h has a code segment as follows:
#if defined(__sh3__)
#define _C_LABEL(x) __CONCAT(_,x)
#else
#define _C_LABEL(x) x
#endif
This is because egcs puts underscores ('_') to C labels when object
format is ELF for SH. For other CPUs, underscores are not prepended
for ELF object format. I don't know why they do it in this manner.
My question is
Do we need to follow this way for NetBSD/sh3?
It causes some problems when you build userland for SH3 ELF. If we
really want underscores on C labels, we need some "fixes", for example
to cdef_elf.h:
#if defined(__sh3__)
#define _C_LABEL(x) __CONCAT(_,x)
+#define _C_LABEL_PREFIX "_"
#else
#define _C_LABEL(x) x
+#define _C_LABEL_PREFIX ""
#endif
#if __STDC__
@@ -57,12 +59,13 @@
#ifndef __DO_NOT_DO_WEAK__
#define __weak_alias(alias,sym) \
- __asm__(".weak " #alias " ; " #alias " = " #sym);
+ __asm__(".weak " _C_LABEL_PREFIX #alias " ; " \
+ _C_LABEL_PREFIX #alias " = " _C_LABEL_PREFIX #sym);
#endif /* !__DO_NOT_DO_WEAK__ */
#define __weak_extern(sym) \
- __asm__(".weak " #sym);
+ __asm__(".weak " _C_LABEL_PREFIX #sym);
#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning." #sym " ; .ascii \"" msg "\" ; .text");
+ __asm__(".section .gnu.warning." _C_LABEL_PREFIX #sym " ; .ascii \"" msg "\" ; .text");
#else /* !__STDC__ */
Similar changes are required for sys/arch/sh3/include/asm.h. Some
utilities to handle object files (ex. crunchgen) need to be modified,
too.
It seems to me that keeping consistent with other ports and not having
prefix to C label is better and easier solution. I haven't tried to
build the tree with such egcs configuration yet, but by quick research
on LinuxSH mailing list, I found they have their own configuration not
to put underscores to C label for SH3 ELF.
Comments?
----
bsh.