op-darwin.sed revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
0N/A# $Id$
2362N/A## @file
0N/A#
0N/A# SED script for transforming op.S (i386 ELF from GNU/linux) into
0N/A# something that the Darwin (Mac OS X) assembler can make use of.
0N/A#
2362N/A
0N/A#
2362N/A# Copyright (C) 2006 InnoTek Systemberatung GmbH
0N/A#
0N/A# This file is part of VirtualBox Open Source Edition (OSE), as
0N/A# available from http://www.virtualbox.org. This file is free software;
0N/A# you can redistribute it and/or modify it under the terms of the GNU
0N/A# General Public License as published by the Free Software Foundation,
0N/A# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
0N/A# distribution. VirtualBox OSE is distributed in the hope that it will
0N/A# be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A#
0N/A# If you received this file as part of a commercial VirtualBox
0N/A# distribution, then only the terms of your commercial VirtualBox
2362N/A# license agreement apply instead of the previous paragraph.
2362N/A#
2362N/A
0N/A# This is a generic transformation, only encountered with i386-elf-gcc-3.4.3 so far.
0N/As/^\([[:blank:]]*\)\//\1#/
0N/A
0N/A# Darwin doesn't grok .type and .size, remove those lines.
0N/A/^[[:blank:]]*\.type[[:blank:]]/d
0N/A/^[[:blank:]]*\.size[[:blank:]]/d
0N/A
0N/A# Darwin names the .rodata section '.const'.
0N/As/^[[:blank:]]*\.section[[:blank:]][[:blank:]]*\.rodata[[:blank:]]*$/\t.const/
0N/A
0N/A# Darwin doesn't grok the the .note.GNU-stack section, remove that line.
0N/A/^[[:blank:]]*\.section[[:blank:]][[:blank:]]*\.note\.GNU-stack,/d
0N/A
0N/A# .zero seems to be similar to .spaces...
0N/As/^\([[:blank:]]*\)\.zero[[:blank:]][[:blank:]]*\([0-9][0-9]*\)/\1.space \2/
0N/A
0N/A# It looks like if .align is taking a byte count on linux and a power of
0N/A# two on Darwin, translate to power of two.
0N/As/\.align 128/\.align 7/
0N/As/\.align 64/\.align 6/
0N/As/\.align 32/\.align 5/
0N/As/\.align 16/\.align 4/
0N/As/\.align 8/\.align 3/
0N/As/\.align 4/\.align 2/
0N/As/\.align 2/\.align 1/
0N/A
0N/A
0N/A# Darwin uses underscore prefixed names like the DOS based i386 OSes
0N/A# linux does. So, all global symbols needs to be translated.
0N/As/^[[:blank:]]*\.globl[[:blank:]][[:blank:]]*\([^\t\n ]*\)[[:blank:]]*$/#define \1 _\1\n.globl \1/
0N/A
0N/A# special hack for __op_labelN
0N/As/__op_label\([0-9]\)/___op_label\1/g
0N/A
0N/A