aboutsummaryrefslogtreecommitdiff
path: root/tccasm.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2016-05-01 22:38:38 +0300
committerseyko <seyko2@gmail.com>2016-05-01 22:38:38 +0300
commit6afe668ec7a11736a9418a46370af89a8c657ee8 (patch)
tree754e61e7f4d077df6e89e5d82dc0e3638474c6ed /tccasm.c
parent09a78412f071d189f52caed0866d02a608eb2d56 (diff)
downloadtinycc-6afe668ec7a11736a9418a46370af89a8c657ee8.tar.gz
tinycc-6afe668ec7a11736a9418a46370af89a8c657ee8.tar.bz2
__asm__() outside function
gcc/pcc allow __asm__() outside a function body: extern void vide(void); __asm__("vide: ret"); There is many such code in the Linux kernels.
Diffstat (limited to 'tccasm.c')
-rw-r--r--tccasm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tccasm.c b/tccasm.c
index 72121e4..3fd69f7 100644
--- a/tccasm.c
+++ b/tccasm.c
@@ -824,6 +824,16 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
opcode = tok;
next();
if (tok == ':') {
+ /* handle "extern void vide(void); __asm__("vide: ret");" as
+ "__asm__("globl vide\nvide: ret");" */
+ Sym *sym = sym_find(opcode);
+ if (sym && (sym->type.t & VT_EXTERN) && nocode_wanted) {
+ sym = label_find(opcode);
+ if (!sym) {
+ sym = label_push(&s1->asm_labels, opcode, 0);
+ sym->type.t = VT_VOID;
+ }
+ }
/* new label */
asm_new_label(s1, opcode, 0);
next();