@echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver
@mv -f .ver $@
+comma := ,
+
init/version.o: init/version.c include/linux/compile.h include/config/MARKER
- $(CC) $(CFLAGS) $(CFLAGS_KERNEL) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c
+ $(CC) $(CFLAGS) $(CFLAGS_KERNEL) -DUTS_MACHINE='"$(ARCH)"' -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c -o init/version.o init/version.c
init/main.o: init/main.c include/config/MARKER
- $(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -c -o $*.o $<
+ $(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c -o $*.o $<
init/do_mounts.o: init/do_mounts.c include/config/MARKER
$(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -c -o $*.o $<
unexport subdir-n
unexport subdir-
+comma := ,
+
#
# Get things started.
#
$(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
%.o: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $<
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
ifneq "$(strip $(export-objs))" ""
$(export-objs): $(export-objs:.o=.c) $(TOPDIR)/include/linux/modversions.h
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
*(.fixup)
*(.text.__*)
}
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
_etext = . ; /* End of text section */
__etext = .;
head.o: head.S
$(CC) $(AFLAGS) -traditional -c head.S
+comma := ,
+
misc.o: misc.c
- $(CC) $(CFLAGS) -c misc.c
+ $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c
piggy.o: $(SYSTEM)
tmppiggy=_tmp_$$$$piggy; \
.quad 0x0000000000000000 /* 0x98 not used */
/* Per CPU segments */
.fill NR_CPUS*4,8,0 /* space for TSS's and LDT's */
-
-/*
- * This is to aid debugging, the various locking macros will be putting
- * code fragments here. When an oops occurs we'd rather know that it's
- * inside the .text.lock section rather than as some offset from whatever
- * function happens to be last in the .text segment.
- */
-.section .text.lock
-ENTRY(stext_lock)
*(.fixup)
*(.gnu.warning)
} = 0x9090
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
_etext = .; /* End of text section */
fprom: $(OBJ)
$(LD) -static -Tfprom.lds -o fprom $(OBJ) $(LIB)
+comma := ,
+
.S.o:
$(CC) -D__ASSEMBLY__ $(AFLAGS) $(AFLAGS_KERNEL) -c -o $*.o $<
.c.o:
- $(CC) $(CFLAGS) $(CFLAGS_KERNEL) -c -o $*.o $<
+ $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_KERNEL) -c -o $*.o $<
clean:
rm -f *.o fprom
offsets.h: print_offsets
./print_offsets > offsets.h
+comma := ,
+
print_offsets: print_offsets.c FORCE_RECOMPILE
- $(CC) $(CFLAGS) print_offsets.c -o $@
+ $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) print_offsets.c -o $@
FORCE_RECOMPILE:
$(AWK) -f print_offsets.awk $^ > $@
print_offsets.s: print_offsets.c
- $(CC) $(CFLAGS) -S print_offsets.c -o $@
+ $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -S print_offsets.c -o $@
endif
*(.head)
*(.text)
*(.fixup)
- *(.text.lock) /* out-of-line lock text */
*(.gnu.warning)
} = 0x4e75
.kstrtab : { *(.kstrtab) }
.text : {
*(.text)
*(.fixup)
- *(.text.lock) /* out-of-line lock text */
*(.gnu.warning)
} = 0x4e75
.rodata : { *(.rodata) *(.rodata.*) }
*(.fixup)
*(.gnu.warning)
} = 0x0700
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) }
.kstrtab : { *(.kstrtab) }
*(.fixup)
*(.gnu.warning)
} = 0x0700
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) *(.rodata.*) }
.kstrtab : { *(.kstrtab) }
*(.fixup)
*(.gnu.warning)
} = 0x0700
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) }
.kstrtab : { *(.kstrtab) }
*(.fixup)
*(.gnu.warning)
} = 0x0700
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) *(.rodata.*) }
.kstrtab : { *(.kstrtab) }
*(.fixup)
*(.gnu.warning)
} = 0x0009
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) *(.rodata.*) }
.kstrtab : { *(.kstrtab) }
asm volatile(LOCK "subl $1,(%0)\n\t" \
"js 2f\n" \
"1:\n" \
- ".section .text.lock,\"ax\"\n" \
+ LOCK_SECTION_START("") \
"2:\tcall " helper "\n\t" \
"jmp 1b\n" \
- ".previous" \
+ LOCK_SECTION_END \
::"a" (rw) : "memory")
#define __build_read_lock_const(rw, helper) \
asm volatile(LOCK "subl $1,%0\n\t" \
"js 2f\n" \
"1:\n" \
- ".section .text.lock,\"ax\"\n" \
+ LOCK_SECTION_START("") \
"2:\tpushl %%eax\n\t" \
"leal %0,%%eax\n\t" \
"call " helper "\n\t" \
"popl %%eax\n\t" \
"jmp 1b\n" \
- ".previous" \
+ LOCK_SECTION_END \
:"=m" (*(volatile int *)rw) : : "memory")
#define __build_read_lock(rw, helper) do { \
asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
"jnz 2f\n" \
"1:\n" \
- ".section .text.lock,\"ax\"\n" \
+ LOCK_SECTION_START("") \
"2:\tcall " helper "\n\t" \
"jmp 1b\n" \
- ".previous" \
+ LOCK_SECTION_END \
::"a" (rw) : "memory")
#define __build_write_lock_const(rw, helper) \
asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
"jnz 2f\n" \
"1:\n" \
- ".section .text.lock,\"ax\"\n" \
+ LOCK_SECTION_START("") \
"2:\tpushl %%eax\n\t" \
"leal %0,%%eax\n\t" \
"call " helper "\n\t" \
"popl %%eax\n\t" \
"jmp 1b\n" \
- ".previous" \
+ LOCK_SECTION_END \
:"=m" (*(volatile int *)rw) : : "memory")
#define __build_write_lock(rw, helper) do { \
LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */
" js 2f\n\t" /* jump if we weren't granted the lock */
"1:\n\t"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\n\t"
" pushl %%ecx\n\t"
" pushl %%edx\n\t"
" popl %%edx\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
- ".previous"
+ LOCK_SECTION_END
"# ending down_read\n\t"
: "+m"(sem->count)
: "a"(sem)
" testl %0,%0\n\t" /* was the count 0 before? */
" jnz 2f\n\t" /* jump if we weren't granted the lock */
"1:\n\t"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\n\t"
" pushl %%ecx\n\t"
" call rwsem_down_write_failed\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
- ".previous\n"
+ LOCK_SECTION_END
"# ending down_write"
: "+d"(tmp), "+m"(sem->count)
: "a"(sem)
LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
" js 2f\n\t" /* jump if the lock is being waited upon */
"1:\n\t"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\n\t"
" decw %%dx\n\t" /* do nothing if still outstanding active readers */
" jnz 1b\n\t"
" call rwsem_wake\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
- ".previous\n"
+ LOCK_SECTION_END
"# ending __up_read\n"
: "+m"(sem->count), "+d"(tmp)
: "a"(sem)
LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
" jnz 2f\n\t" /* jump if the lock is being waited upon */
"1:\n\t"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\n\t"
" decw %%dx\n\t" /* did the active count reduce to 0? */
" jnz 1b\n\t" /* jump back if not */
" call rwsem_wake\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
- ".previous\n"
+ LOCK_SECTION_END
"# ending __up_write\n"
: "+m"(sem->count)
: "a"(sem), "i"(-RWSEM_ACTIVE_WRITE_BIAS)
LOCK "decl %0\n\t" /* --sem->count */
"js 2f\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\tcall __down_failed\n\t"
"jmp 1b\n"
- ".previous"
+ LOCK_SECTION_END
:"=m" (sem->count)
:"c" (sem)
:"memory");
"js 2f\n\t"
"xorl %0,%0\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\tcall __down_failed_interruptible\n\t"
"jmp 1b\n"
- ".previous"
+ LOCK_SECTION_END
:"=a" (result), "=m" (sem->count)
:"c" (sem)
:"memory");
"js 2f\n\t"
"xorl %0,%0\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\tcall __down_failed_trylock\n\t"
"jmp 1b\n"
- ".previous"
+ LOCK_SECTION_END
:"=a" (result), "=m" (sem->count)
:"c" (sem)
:"memory");
LOCK "incl %0\n\t" /* ++sem->count */
"jle 2f\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
+ LOCK_SECTION_START("")
"2:\tcall __up_wakeup\n\t"
"jmp 1b\n"
- ".previous"
+ LOCK_SECTION_END
+ ".subsection 0\n"
:"=m" (sem->count)
:"c" (sem)
:"memory");
"jnz 2f;" \
"1:;" \
\
- ".section .text.lock,\"ax\";" \
+ LOCK_SECTION_START("") \
"2: pushl %%eax; pushl %%ecx; pushl %%edx;" \
"call %c1;" \
"popl %%edx; popl %%ecx; popl %%eax;" \
"jmp 1b;" \
- ".previous;" \
+ LOCK_SECTION_END \
\
: /* no output */ \
: "r" (ptr), "i" (do_softirq) \
"\n1:\t" \
"lock ; decb %0\n\t" \
"js 2f\n" \
- ".section .text.lock,\"ax\"\n" \
+ LOCK_SECTION_START("") \
"2:\t" \
"cmpb $0,%0\n\t" \
"rep;nop\n\t" \
"jle 2b\n\t" \
"jmp 1b\n" \
- ".previous"
+ LOCK_SECTION_END
/*
* This works. Despite all the confusion.
#include <linux/wait.h>
#include <linux/spinlock.h>
#include <linux/rwsem.h>
+#include <linux/stringify.h>
#include <asm/system.h>
#include <asm/atomic.h>
"subql #1,%0@\n\t"
"jmi 2f\n\t"
"1:\n"
- ".section .text.lock,\"ax\"\n"
- ".even\n"
+ LOCK_SECTION_START(".even\n\t")
"2:\tpea 1b\n\t"
"jbra __down_failed\n"
- ".previous"
+ LOCK_SECTION_END
: /* no outputs */
: "a" (sem1)
: "memory");
"jmi 2f\n\t"
"clrl %0\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
- ".even\n"
+ LOCK_SECTION_START(".even\n\t")
"2:\tpea 1b\n\t"
"jbra __down_failed_interruptible\n"
- ".previous"
+ LOCK_SECTION_END
: "=d" (result)
: "a" (sem1)
: "memory");
"jmi 2f\n\t"
"clrl %0\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
- ".even\n"
+ LOCK_SECTION_START(".even\n\t")
"2:\tpea 1b\n\t"
"jbra __down_failed_trylock\n"
- ".previous"
+ LOCK_SECTION_END
: "=d" (result)
: "a" (sem1)
: "memory");
"addql #1,%0@\n\t"
"jle 2f\n"
"1:\n"
- ".section .text.lock,\"ax\"\n"
- ".even\n"
+ LOCK_SECTION_START(".even\n\t")
"2:\t"
"pea 1b\n\t"
"jbra __up_wakeup\n"
- ".previous"
+ LOCK_SECTION_END
: /* no outputs */
: "a" (sem1)
: "memory");
*
*/
-/* if you're going to use out-of-line slowpaths, use .section .lock.text,
- * not .text.lock or the -ffunction-sections monster will eat you alive
- */
-
#include <linux/spinlock.h>
#include <linux/rwsem.h>
#include <asm/system.h>
-/* if you're going to use out-of-line slowpaths, use .section .lock.text,
- * not .text.lock or the -ffunction-sections monster will eat you alive
- */
-
/* we seem to be the only architecture that uses 0 to mean locked - but we
* have to. prumpf */
if (!__r) local_bh_enable(); \
__r; })
+/* Must define these before including other files, inline functions need them */
+
+#include <linux/stringify.h>
+
+#define LOCK_SECTION_NAME \
+ ".text.lock." __stringify(KBUILD_BASENAME)
+
+#define LOCK_SECTION_START(extra) \
+ ".subsection 1\n\t" \
+ extra \
+ ".ifndef " LOCK_SECTION_NAME "\n\t" \
+ LOCK_SECTION_NAME ":\n\t" \
+ ".endif\n\t"
+
+#define LOCK_SECTION_END \
+ ".previous\n\t"
+
#ifdef CONFIG_SMP
#include <asm/spinlock.h>
--- /dev/null
+#ifndef __LINUX_STRINGIFY_H
+#define __LINUX_STRINGIFY_H
+
+/* Indirect stringification. Doing two levels allows the parameter to be a
+ * macro itself. For example, compile with -DFOO=bar, __stringify(FOO)
+ * converts to "bar".
+ */
+
+#define __stringify_1(x) #x
+#define __stringify(x) __stringify_1(x)
+
+#endif /* !__LINUX_STRINGIFY_H */