#!/bin/sh

# find and replace:
# .$1.$2[alnums_underscores_or_dots] -> .$2[alnums_underscores_or_dots].$1
repl() {
    grep -rl '\.'$1'\.'$2 . | xargs -n1 sed 's/\.'$1'\.'$2'\([a-z0-9_.]*\)/.'$2'\1.'$1'/g' -i
    echo "Done: .$1.$2"
}

repl text head
repl text init
repl text start
repl text lock
repl text exit
repl text do_
repl text sys_
repl text rtsigreturn
repl text sigreturn
repl text vsyscall
repl text compressed
repl text ptr
repl text ivt

repl data percpu
repl data read_mostly
repl data cacheline_aligned
repl data init
repl data nosave
repl data page_aligned
repl data lock_aligned
repl data patch
repl data exit
repl data idt
repl data compressed
repl data gate
repl data boot
repl data vm0

# bss is special.
grep -Frl '.bss.page_aligned' . | xargs -n1 sed 's/\.bss\.page_aligned/.bss.k.page_aligned/g' -i

# Not changed by the above:
#
# cris: .text.__*
# powerpc: .data.rel*
# parisc:
#  .data.vmpages : {...}
# frv: .bss.stack    : { *(.bss) }
# xtensa:                *(.literal .text.literal .text)
# avr32:                 *(.text.reset)
