diff options
author | Wenzong Fan <wenzong.fan@windriver.com> | 2015-09-14 04:45:06 -0400 |
---|---|---|
committer | Joe MacDonald <joe_macdonald@mentor.com> | 2015-09-21 10:42:27 -0400 |
commit | 463f97bfd1180475540b7d91e3fec6a2b33966bd (patch) | |
tree | 1248c6695cfd8c97385ef61359766ca4e8df6825 | |
parent | dfa1054f3330af3fa18f522488af88e4269e394c (diff) | |
download | meta-selinux-463f97bfd1180475540b7d91e3fec6a2b33966bd.tar.gz |
audit/auvirt: get inline functions work with both gnu89 & gnu11
After gcc upgraded to gcc5, and if the codes are compiled without
optimization (-O0), and the below error will happen:
auvirt.c:484: undefined reference to `copy_str'
auvirt.c:667: undefined reference to `is_resource'
collect2: error: ld returned 1 exit status
gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that
exactly one C source file has the callable copy of the inline function.
Consider the following program:
inline int
foo (void)
{
return 42;
}
int
main (void)
{
return foo ();
}
The program above will not link with the C99 inline semantics, because
no out-of-line function foo is generated. To fix this, either mark the
function foo as static, or add the following declaration:
static inline int foo (void);
More information refer to: https://gcc.gnu.org/gcc-5/porting_to.html
Note: using "extern inline" will fail to build with gcc4.x, so replace
inline with "static inline".
Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
-rw-r--r-- | recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch | 71 | ||||
-rw-r--r-- | recipes-security/audit/audit_2.4.3.bb | 1 |
2 files changed, 72 insertions, 0 deletions
diff --git a/recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch b/recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch new file mode 100644 index 0000000..578cfc1 --- /dev/null +++ b/recipes-security/audit/audit/audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch | |||
@@ -0,0 +1,71 @@ | |||
1 | From 15036dd4fa9eb209f5e148c6f7ee081f5ca78fa4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Wenzong Fan <wenzong.fan@windriver.com> | ||
3 | Date: Fri, 11 Sep 2015 03:37:13 -0400 | ||
4 | Subject: [PATCH] audit/auvirt: get inline functions work with both gnu89 & gnu11 | ||
5 | |||
6 | After gcc upgraded to gcc5, and if the codes are compiled without | ||
7 | optimization (-O0), and the below error will happen: | ||
8 | |||
9 | auvirt.c:484: undefined reference to `copy_str' | ||
10 | auvirt.c:667: undefined reference to `is_resource' | ||
11 | collect2: error: ld returned 1 exit status | ||
12 | |||
13 | gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that | ||
14 | exactly one C source file has the callable copy of the inline function. | ||
15 | Consider the following program: | ||
16 | |||
17 | inline int | ||
18 | foo (void) | ||
19 | { | ||
20 | return 42; | ||
21 | } | ||
22 | |||
23 | int | ||
24 | main (void) | ||
25 | { | ||
26 | return foo (); | ||
27 | } | ||
28 | |||
29 | The program above will not link with the C99 inline semantics, because | ||
30 | no out-of-line function foo is generated. To fix this, either mark the | ||
31 | function foo as static, or add the following declaration: | ||
32 | |||
33 | static inline int foo (void); | ||
34 | |||
35 | More information refer to: https://gcc.gnu.org/gcc-5/porting_to.html | ||
36 | |||
37 | Note: using "extern inline" will fail to build with gcc4.x, so replace | ||
38 | inline with "static inline". | ||
39 | |||
40 | Upstream-Status: Pending | ||
41 | |||
42 | Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com> | ||
43 | --- | ||
44 | tools/auvirt/auvirt.c | 4 ++-- | ||
45 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
46 | |||
47 | diff --git a/tools/auvirt/auvirt.c b/tools/auvirt/auvirt.c | ||
48 | index 655c454..b16d718 100644 | ||
49 | --- a/tools/auvirt/auvirt.c | ||
50 | +++ b/tools/auvirt/auvirt.c | ||
51 | @@ -138,7 +138,7 @@ void event_free(struct event *event) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | -inline char *copy_str(const char *str) | ||
56 | +static inline char *copy_str(const char *str) | ||
57 | { | ||
58 | return (str) ? strdup(str) : NULL; | ||
59 | } | ||
60 | @@ -650,7 +650,7 @@ int process_control_event(auparse_state_t *au) | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | -inline int is_resource(const char *res) | ||
65 | +static inline int is_resource(const char *res) | ||
66 | { | ||
67 | if (res == NULL || | ||
68 | res[0] == '\0' || | ||
69 | -- | ||
70 | 1.9.1 | ||
71 | |||
diff --git a/recipes-security/audit/audit_2.4.3.bb b/recipes-security/audit/audit_2.4.3.bb index 0fcf145..f0fa949 100644 --- a/recipes-security/audit/audit_2.4.3.bb +++ b/recipes-security/audit/audit_2.4.3.bb | |||
@@ -15,6 +15,7 @@ SRC_URI = "http://people.redhat.com/sgrubb/audit/audit-${PV}.tar.gz \ | |||
15 | file://auditd \ | 15 | file://auditd \ |
16 | file://auditd.service \ | 16 | file://auditd.service \ |
17 | file://audit-volatile.conf \ | 17 | file://audit-volatile.conf \ |
18 | file://audit-auvirt-get-inline-functions-work-with-gnu89-gnu11.patch \ | ||
18 | " | 19 | " |
19 | SRC_URI[md5sum] = "544d863af2016b76afd8d1691b251164" | 20 | SRC_URI[md5sum] = "544d863af2016b76afd8d1691b251164" |
20 | SRC_URI[sha256sum] = "9c914704fecc602e143e37152f3efbab2469692684c1a8cc1b801c1b49c7abc6" | 21 | SRC_URI[sha256sum] = "9c914704fecc602e143e37152f3efbab2469692684c1a8cc1b801c1b49c7abc6" |