bnc#382137 DocxAttributeOutput: don't store address of local variable
[LibreOffice.git] / solenv / bin / addsym-macosx.sh
blobb7bcbb86d937c8f3ee5c1abd8dad117256bbd022
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # This script is needed in the process of generating exported
21 # symbols list out of map files on Mac OS X (see also #i69351#)
22 # The magic generating the regular expression from the temporary
23 # mapfile containing only star and question mark symbols
25 # The script has to be called as follows:
26 # nm -gx <file>.o | addsym-macosx.sh <file-with-wildcard-symbols> <temporary-file-where-to-write-the-search-expression-to>
27 # See tg_shl.mk for an example of how to use the script
29 # Replace every * with .* and every ? with . to get awk expression
30 # Put ^ at the beginning of every expression
31 # Put $ at the beginning of every expression
32 # Connect them all on one line, separated by |
33 # Remove | at the end of this regular expression because the last end
34 # of line was also replaced by |
36 cat $1 | sed 's#*#.*#g
37 s#?#.#g
38 s#^#^#
39 s#$#$#' | tr '\n' '|' | sed "s#|\$##" >$2
41 # Please note that the awk expression expects to get the output of 'nm -gx'!
43 # The fields in the nm -gx output are apparently (see
44 # /usr/include/mach-o/nlist.h>):
46 # xxxxxxxx xx xx xxxx xxxxxxxx symbol
47 # ! ! ! ! n_value
48 # ! ! ! n_desc
49 # ! ! n_sect
50 # ! n_type
51 # n_strx
53 # Original comment:
54 # On Panther we have to filter out symbols with a value "1f" otherwise external
55 # symbols will erroneously be added to the generated export symbols list file.
57 # Of course it isn't actually the "value" (n_value) of the symbol that
58 # is meant, but (as is seen from the use of $2) the n_type .
60 # Now, what does a n_type of 1f actually mean? The N_PEXT bit (0x10)
61 # is on and the N_EXT (0x01) bit is on. It is what in Mach-O
62 # documentation is called "private external". This includes symbols
63 # produced by using -fvisibility=hidden. Whether that is a problem I
64 # don't know.
66 awk -v SYMBOLSREGEXP="`cat $2`" '
67 match ($6,SYMBOLSREGEXP) > 0 && $6 !~ /_GLOBAL_/ { if (($2 != 1) && ( $2 != "1f" ) ) print $6 }'