File: Makefile.common

package info (click to toggle)
libpulp 0.3.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,976 kB
  • sloc: ansic: 11,792; python: 1,216; sh: 881; makefile: 871; cpp: 582; asm: 387
file content (75 lines) | stat: -rw-r--r-- 3,071 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#   libpulp - User-space Livepatching Library
#
#   Copyright (C) 2020-2021 SUSE Software Solutions GmbH
#
#   This file is part of libpulp.
#
#   libpulp is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Lesser General Public
#   License as published by the Free Software Foundation; either
#   version 2.1 of the License, or (at your option) any later version.
#
#   libpulp is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   Lesser General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with libpulp.  If not, see <http://www.gnu.org/licenses/>.

# ULP tools location.
ULP = $(top_builddir)/tools/ulp
ULP_POST = $(ULP) post
ULP_PACKER = $(ULP) packer
ULP_REVERSE = $(ULP) reverse
ULP_EXTRACT = $(ULP) extract

# Build and link requirements for live-patchable (target) libraries.
TARGET_CFLAGS = \
  -fPIC \
  -fpatchable-function-entry=$(ULP_NOPS_LEN),$(PRE_NOPS_LEN) \
  -fno-inline \
  $(AM_CFLAGS)
TARGET_LDFLAGS = \
  --build-id \
  -Wl,--hash-style=sysv \ # Ubuntu seems to default to gnu, so be clear we ...
  $(AM_LDFLAGS) # ... want old style hash sections, else DT_HASH is empty.

# In libtool, convenience libraries are not installed, so they do not
# need -rpath, which causes them to be statically linked.  However,
# libpulp can only live patch dynamically linked libraries, so pass
# -rpath to libtool, which causes the linking to become dynamic.
CONVENIENCE_LDFLAGS = -rpath $(libdir) $(AM_LDFLAGS)

# The following custom rules are triggered by <testname>_DEPENDENCIES:

# This rule causes the target library to be post-processed with
# ulp_post, which replaces single-byte with multi-byte nops. Files with
# .post extension track whether the respective libraries have already
# been post-processed.
#
# Since we also support to specify the target library as a dump of the
# relevant informations (name, symbols, build id), we also have extra
# logic to generate such dumps (JSON file).
.libs/lib%.post: lib%.la
	$(ULP_POST) .libs/lib$*.so.0
	$(ULP_EXTRACT) .libs/lib$*.so.0 -o .libs/lib$*.so.0.json
	touch $@

# These rules cause the livepatch metadata to be built. The .ulp and
# .dsc targets depends on check_LTLIBRARIES, because .la targets
# indirectly produce the .so files they need (it is impossible to have
# .ulp and .dsc targets depend directly on .so files, because libtool
# does not create .so targets).
%.dsc: %.in $(check_LTLIBRARIES)
	sed -e "s|__ABS_BUILDDIR__|$(abs_builddir)|" $< > $*.tmp
	$(top_srcdir)/tests/offsets.py $*.tmp $@
	rm -f $*.tmp

# This rule build the .ulp file, which at some point were used to hold
# the compiled metadata description. Today it is directly integrated
# into the .so file which holds the livepatch code, within the .ulp
# and .ulp.rev section.
%.ulp: %.dsc $(check_LTLIBRARIES)
	$(ULP_PACKER) $< #-o $@
	echo Maintained here for legacy reasons > $@