Commit b5635319 authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] text.lock -> subsection changes.

Make spinlocks etc use subsections of their parent sections instead of
an ELF section of their own - needed for newer binutils when the parent
sector is removed. 
parent 168c9069
......@@ -332,11 +332,13 @@ include/linux/version.h: ./Makefile
@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 $<
......
......@@ -31,6 +31,8 @@ unexport subdir-m
unexport subdir-n
unexport subdir-
comma := ,
#
# Get things started.
#
......@@ -54,7 +56,7 @@ ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-))
$(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 += $@' ; \
......@@ -270,7 +272,7 @@ endif # CONFIG_MODVERSIONS
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 += $@' ; \
......
......@@ -24,7 +24,6 @@ SECTIONS
*(.fixup)
*(.text.__*)
}
.text.lock : { *(.text.lock) } /* out-of-line lock text */
_etext = . ; /* End of text section */
__etext = .;
......
......@@ -32,8 +32,10 @@ bvmlinux: piggy.o $(OBJECTS)
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; \
......
......@@ -456,12 +456,3 @@ ENTRY(gdt_table)
.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)
......@@ -13,7 +13,6 @@ SECTIONS
*(.fixup)
*(.gnu.warning)
} = 0x9090
.text.lock : { *(.text.lock) } /* out-of-line lock text */
_etext = .; /* End of text section */
......
......@@ -18,10 +18,12 @@ obj-y=fprom
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
......
......@@ -31,8 +31,10 @@ ifeq ($(CROSS_COMPILE),)
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:
......@@ -42,7 +44,7 @@ offsets.h: print_offsets.s
$(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
......
......@@ -10,7 +10,6 @@ SECTIONS
*(.head)
*(.text)
*(.fixup)
*(.text.lock) /* out-of-line lock text */
*(.gnu.warning)
} = 0x4e75
.kstrtab : { *(.kstrtab) }
......
......@@ -9,7 +9,6 @@ SECTIONS
.text : {
*(.text)
*(.fixup)
*(.text.lock) /* out-of-line lock text */
*(.gnu.warning)
} = 0x4e75
.rodata : { *(.rodata) *(.rodata.*) }
......
......@@ -13,7 +13,6 @@ SECTIONS
*(.fixup)
*(.gnu.warning)
} = 0x0700
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) }
.kstrtab : { *(.kstrtab) }
......
......@@ -13,7 +13,6 @@ SECTIONS
*(.fixup)
*(.gnu.warning)
} = 0x0700
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) *(.rodata.*) }
.kstrtab : { *(.kstrtab) }
......
......@@ -13,7 +13,6 @@ SECTIONS
*(.fixup)
*(.gnu.warning)
} = 0x0700
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) }
.kstrtab : { *(.kstrtab) }
......
......@@ -13,7 +13,6 @@ SECTIONS
*(.fixup)
*(.gnu.warning)
} = 0x0700
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) *(.rodata.*) }
.kstrtab : { *(.kstrtab) }
......
......@@ -23,7 +23,6 @@ SECTIONS
*(.fixup)
*(.gnu.warning)
} = 0x0009
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) *(.rodata.*) }
.kstrtab : { *(.kstrtab) }
......
......@@ -24,23 +24,23 @@
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 { \
......@@ -54,23 +54,23 @@
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 { \
......
......@@ -101,7 +101,7 @@ static inline void __down_read(struct rw_semaphore *sem)
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"
......@@ -109,7 +109,7 @@ LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value
" 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)
......@@ -130,13 +130,13 @@ LOCK_PREFIX " xadd %0,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old
" 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)
......@@ -154,7 +154,7 @@ static inline void __up_read(struct rw_semaphore *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"
......@@ -162,7 +162,7 @@ LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old valu
" 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)
......@@ -180,7 +180,7 @@ static inline void __up_write(struct rw_semaphore *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 */
......@@ -188,7 +188,7 @@ LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 ->
" 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)
......
......@@ -122,10 +122,10 @@ static inline void down(struct semaphore * sem)
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");
......@@ -149,10 +149,10 @@ static inline int down_interruptible(struct semaphore * sem)
"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");
......@@ -177,10 +177,10 @@ static inline int down_trylock(struct semaphore * sem)
"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");
......@@ -203,10 +203,11 @@ static inline void up(struct semaphore * sem)
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");
......
......@@ -33,12 +33,12 @@ do { \
"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) \
......
......@@ -56,13 +56,13 @@ typedef struct {
"\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.
......
......@@ -9,6 +9,7 @@
#include <linux/wait.h>
#include <linux/spinlock.h>
#include <linux/rwsem.h>
#include <linux/stringify.h>
#include <asm/system.h>
#include <asm/atomic.h>
......@@ -94,11 +95,10 @@ extern inline void down(struct semaphore * sem)
"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");
......@@ -119,11 +119,10 @@ extern inline int down_interruptible(struct semaphore * sem)
"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");
......@@ -145,11 +144,10 @@ extern inline int down_trylock(struct semaphore * sem)
"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");
......@@ -175,12 +173,11 @@ extern inline void up(struct semaphore * sem)
"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");
......
......@@ -12,10 +12,6 @@
*
*/
/* 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>
......
......@@ -3,10 +3,6 @@
#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 */
......
......@@ -35,6 +35,23 @@
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>
......
#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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment