summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2025-08-22 00:43:06 +0200
committerSteve Sakoman <steve@sakoman.com>2025-09-01 08:30:56 -0700
commit41e1323758aef317237a457d897334184e9ea364 (patch)
treef219c66904e9698de69f9d76e27e4a15396a35b4 /meta
parentcb17b874de640dfe135401c324c9e74c103e8ce5 (diff)
downloadpoky-41e1323758aef317237a457d897334184e9ea364.tar.gz
binutils: fix build with gcc-15
(From OE-Core rev: f7d791585632b7db5f80090c92b5389eacd60fab) Signed-off-by: Martin Jansa <martin.jansa@gmail.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/binutils/binutils-2.42.inc4
-rw-r--r--meta/recipes-devtools/binutils/binutils/0018-opcodes-fix-std-gnu23-compatibility-wrt-static_assert.patch89
-rw-r--r--meta/recipes-devtools/binutils/binutils/0019-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch767
-rw-r--r--meta/recipes-devtools/binutils/binutils/0020-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch606
-rw-r--r--meta/recipes-devtools/binutils/binutils/0021-gprofng-fix-build-with-std-gnu23.patch196
5 files changed, 1662 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.42.inc b/meta/recipes-devtools/binutils/binutils-2.42.inc
index fb34ea9763..e791cd2b13 100644
--- a/meta/recipes-devtools/binutils/binutils-2.42.inc
+++ b/meta/recipes-devtools/binutils/binutils-2.42.inc
@@ -39,6 +39,10 @@ SRC_URI = "\
39 file://0015-gprofng-change-use-of-bignum-to-bigint.patch \ 39 file://0015-gprofng-change-use-of-bignum-to-bigint.patch \
40 file://0016-CVE-2024-53589.patch \ 40 file://0016-CVE-2024-53589.patch \
41 file://0017-dlltool-file-name-too-long.patch \ 41 file://0017-dlltool-file-name-too-long.patch \
42 file://0018-opcodes-fix-std-gnu23-compatibility-wrt-static_assert.patch \
43 file://0019-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch \
44 file://0020-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch \
45 file://0021-gprofng-fix-build-with-std-gnu23.patch \
42 file://0018-CVE-2025-0840.patch \ 46 file://0018-CVE-2025-0840.patch \
43 file://CVE-2025-1176.patch \ 47 file://CVE-2025-1176.patch \
44 file://CVE-2025-1178.patch \ 48 file://CVE-2025-1178.patch \
diff --git a/meta/recipes-devtools/binutils/binutils/0018-opcodes-fix-std-gnu23-compatibility-wrt-static_assert.patch b/meta/recipes-devtools/binutils/binutils/0018-opcodes-fix-std-gnu23-compatibility-wrt-static_assert.patch
new file mode 100644
index 0000000000..d447ce0d52
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0018-opcodes-fix-std-gnu23-compatibility-wrt-static_assert.patch
@@ -0,0 +1,89 @@
1From 8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4 Mon Sep 17 00:00:00 2001
2From: Sam James <sam@gentoo.org>
3Date: Sat, 16 Nov 2024 05:03:52 +0000
4Subject: [PATCH] opcodes: fix -std=gnu23 compatibility wrt static_assert
5
6static_assert is declared in C23 so we can't reuse that identifier:
7* Define our own static_assert conditionally;
8
9* Rename "static assert" hacks to _N as we do already in some places
10 to avoid a conflict.
11
12ChangeLog:
13 PR ld/32372
14
15 * i386-gen.c (static_assert): Define conditionally.
16 * mips-formats.h (MAPPED_INT): Rename identifier.
17 (MAPPED_REG): Rename identifier.
18 (OPTIONAL_MAPPED_REG): Rename identifier.
19 * s390-opc.c (static_assert): Define conditionally.
20Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4]
21Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
22---
23 opcodes/i386-gen.c | 2 ++
24 opcodes/mips-formats.h | 6 +++---
25 opcodes/s390-opc.c | 2 ++
26 3 files changed, 7 insertions(+), 3 deletions(-)
27
28diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
29index 053b66675c5..7ee8a30310c 100644
30--- a/opcodes/i386-gen.c
31+++ b/opcodes/i386-gen.c
32@@ -30,7 +30,9 @@
33
34 /* Build-time checks are preferrable over runtime ones. Use this construct
35 in preference where possible. */
36+#ifndef static_assert
37 #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
38+#endif
39
40 static const char *program_name = NULL;
41 static int debug = 0;
42diff --git a/opcodes/mips-formats.h b/opcodes/mips-formats.h
43index 90df7100803..c4dec6352bf 100644
44--- a/opcodes/mips-formats.h
45+++ b/opcodes/mips-formats.h
46@@ -49,7 +49,7 @@
47 #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
48 { \
49 typedef char ATTRIBUTE_UNUSED \
50- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
51+ static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
52 static const struct mips_mapped_int_operand op = { \
53 { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
54 }; \
55@@ -83,7 +83,7 @@
56 #define MAPPED_REG(SIZE, LSB, BANK, MAP) \
57 { \
58 typedef char ATTRIBUTE_UNUSED \
59- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
60+ static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
61 static const struct mips_reg_operand op = { \
62 { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
63 }; \
64@@ -93,7 +93,7 @@
65 #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
66 { \
67 typedef char ATTRIBUTE_UNUSED \
68- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
69+ static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
70 static const struct mips_reg_operand op = { \
71 { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
72 }; \
73diff --git a/opcodes/s390-opc.c b/opcodes/s390-opc.c
74index 9d9f0973e55..49efd714157 100644
75--- a/opcodes/s390-opc.c
76+++ b/opcodes/s390-opc.c
77@@ -36,7 +36,9 @@
78
79 /* Build-time checks are preferrable over runtime ones. Use this construct
80 in preference where possible. */
81+#ifndef static_assert
82 #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
83+#endif
84
85 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
86
87--
882.43.7
89
diff --git a/meta/recipes-devtools/binutils/binutils/0019-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch b/meta/recipes-devtools/binutils/binutils/0019-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch
new file mode 100644
index 0000000000..89bd9618bc
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0019-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch
@@ -0,0 +1,767 @@
1From b7888eb5a45772ed2e9a2030c50625a15b5ef795 Mon Sep 17 00:00:00 2001
2From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
3Date: Tue, 3 Sep 2024 21:30:31 -0700
4Subject: [PATCH] Fix 32097 Warnings when building gprofng with Clang
5
6gprofng/ChangeLog
72024-09-03 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>.
8
9 PR gprofng/32097
10 * common/hwcdrv.c: Fix -Wempty-body warnings.
11 * common/hwcentry.h: Fix -Wdeprecated-non-prototype warnings.
12 * common/hwctable.c: Fix -Wdeprecated-non-prototype warnings.
13 * libcollector/collector.c: Likewise.
14 * libcollector/collector.h: Likewise.
15 * libcollector/collectorAPI.c: Likewise.
16 * libcollector/dispatcher.c: Likewise.
17 * libcollector/iotrace.c: Likewise.
18 * libcollector/libcol_util.c: Fix -Wunused-but-set-variable warnings.
19 * libcollector/libcol_util.h: Remove unused declarations.
20 * libcollector/linetrace.c: Fix -Wdeprecated-non-prototype warnings.
21 * src/BaseMetricTreeNode.h: Fix -Wunused-private-field warnings.
22 * src/Dbe.cc: Fix -Wself-assign warnings.
23 * src/DbeSession.cc: Fix -Wunused-but-set-variable warnings.
24 * src/Disasm.cc: Fix -Wunused-const-variable warnings.
25 * src/Experiment.cc: Fix -Wunused-private-field warnings.
26 * src/HashMap.h: Fix -Wself-assign warnings.
27 * src/IOActivity.h: Fix -Wunused-private-field warnings.
28 * src/collctrl.cc: Fix -Wself-assign, -Wparentheses-equality warnings.
29 * src/collctrl.h: Fix -Wunused-private-field warnings.
30 * src/collector_module.h: Fix -Wdeprecated-non-prototype warnings.
31 * src/gp-display-src.cc: Fix -Wunused-private-field warnings.
32 * src/gp-print.h: Fix -Wheader-guard warnings.
33 * src/hwc_intel_icelake.h: Fix -Winitializer-overrides warnings.
34 * src/util.cc: Fix -Wunused-but-set-variable warnings.
35Upstream-Status: Backport [https://github.com/bminor/binutils-gdb/commit/b79c457ca01df82dbe1facb708e45def4584c903]
36Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
37---
38 gprofng/common/hwcdrv.c | 3 ++-
39 gprofng/common/hwcentry.h | 7 +----
40 gprofng/common/hwctable.c | 13 +---------
41 gprofng/libcollector/collector.c | 15 ++++-------
42 gprofng/libcollector/collector.h | 2 +-
43 gprofng/libcollector/collectorAPI.c | 15 ++++++-----
44 gprofng/libcollector/dispatcher.c | 19 ++++++++------
45 gprofng/libcollector/iotrace.c | 12 ++++-----
46 gprofng/libcollector/libcol_util.c | 2 --
47 gprofng/libcollector/libcol_util.h | 6 -----
48 gprofng/libcollector/linetrace.c | 40 +++++++++++++++++------------
49 gprofng/src/BaseMetricTreeNode.h | 1 -
50 gprofng/src/Dbe.cc | 12 ++++-----
51 gprofng/src/DbeSession.cc | 3 ---
52 gprofng/src/Disasm.cc | 1 -
53 gprofng/src/Experiment.cc | 2 --
54 gprofng/src/HashMap.h | 3 +--
55 gprofng/src/IOActivity.h | 1 -
56 gprofng/src/collctrl.cc | 14 +++++-----
57 gprofng/src/collctrl.h | 1 -
58 gprofng/src/collector_module.h | 20 +++++++--------
59 gprofng/src/gp-display-src.cc | 8 ------
60 gprofng/src/gp-print.h | 2 +-
61 gprofng/src/util.cc | 10 +++-----
62 24 files changed, 84 insertions(+), 128 deletions(-)
63
64diff --git a/gprofng/common/hwcdrv.c b/gprofng/common/hwcdrv.c
65index 2d549b0d6a5..fa1ad32430b 100644
66--- a/gprofng/common/hwcdrv.c
67+++ b/gprofng/common/hwcdrv.c
68@@ -650,6 +650,7 @@ read_sample (counter_state_t *ctr_state, int msgsz, uint64_t *rvalue,
69 static void
70 dump_perf_event_attr (struct perf_event_attr *at)
71 {
72+#if defined(DEBUG)
73 TprintfT (DBG_LT2, "dump_perf_event_attr: size=%d type=%d sample_period=%lld\n"
74 " config=0x%llx config1=0x%llx config2=0x%llx wakeup_events=%lld __reserved_1=%lld\n",
75 (int) at->size, (int) at->type, (unsigned long long) at->sample_period,
76@@ -665,13 +666,13 @@ dump_perf_event_attr (struct perf_event_attr *at)
77 DUMP_F (exclude_kernel);
78 DUMP_F (exclude_hv);
79 DUMP_F (exclude_idle);
80- // DUMP_F(xmmap);
81 DUMP_F (comm);
82 DUMP_F (freq);
83 DUMP_F (inherit_stat);
84 DUMP_F (enable_on_exec);
85 DUMP_F (task);
86 DUMP_F (watermark);
87+#endif
88 }
89
90 static void
91diff --git a/gprofng/common/hwcentry.h b/gprofng/common/hwcentry.h
92index a35a363e693..7899875cf96 100644
93--- a/gprofng/common/hwcentry.h
94+++ b/gprofng/common/hwcentry.h
95@@ -202,17 +202,12 @@ extern "C"
96 extern char *hwc_get_docref (char *buf, size_t buflen);
97 /* Return a CPU HWC document reference, or NULL. */
98
99- // TBR
100- extern char *hwc_get_default_cntrs ();
101- /* Return a default HW counter string; may be NULL, or zero-length */
102- /* NULL means none is defined in the table; or zero-length means string defined could not be loaded */
103-
104 extern char *hwc_get_default_cntrs2 (int forKernel, int style);
105 /* like hwc_get_default_cntrs() for style==1 */
106 /* but allows other styles of formatting as well */
107 /* deprecate and eventually remove hwc_get_default_cntrs() */
108
109- extern char *hwc_get_orig_default_cntrs ();
110+ extern char *hwc_get_orig_default_cntrs (int forKernel);
111 /* Get the default HW counter string as set in the table */
112 /* NULL means none is defined in the table */
113
114diff --git a/gprofng/common/hwctable.c b/gprofng/common/hwctable.c
115index d0735132fac..fe9153190e7 100644
116--- a/gprofng/common/hwctable.c
117+++ b/gprofng/common/hwctable.c
118@@ -3231,7 +3231,7 @@ check_tables ()
119 }
120 #endif
121
122-static int try_a_counter ();
123+static int try_a_counter (int forKernel);
124 static void hwc_process_raw_ctrs (int forKernel, Hwcentry ***pstd_out,
125 Hwcentry ***praw_out, Hwcentry ***phidden_out,
126 Hwcentry**static_tables,
127@@ -4321,17 +4321,6 @@ hwc_get_docref (char *buf, size_t buflen)
128 return buf;
129 }
130
131-//TBR:
132-
133-extern char*
134-hwc_get_default_cntrs ()
135-{
136- setup_cpcx ();
137- if (cpcx_default_hwcs[0] != NULL)
138- return strdup (cpcx_default_hwcs[0]); // TBR deprecate this
139- return NULL;
140-}
141-
142 extern char*
143 hwc_get_default_cntrs2 (int forKernel, int style)
144 {
145diff --git a/gprofng/libcollector/collector.c b/gprofng/libcollector/collector.c
146index 39529758600..ef580dcbdd9 100644
147--- a/gprofng/libcollector/collector.c
148+++ b/gprofng/libcollector/collector.c
149@@ -210,15 +210,10 @@ get_collector_interface ()
150 static void
151 collector_module_init (CollectorInterface *col_intf)
152 {
153- int nmodules = 0;
154-
155 ModuleInitFunc next_init = (ModuleInitFunc) dlsym (RTLD_DEFAULT, "__collector_module_init");
156 if (next_init != NULL)
157- {
158- nmodules++;
159- next_init (col_intf);
160- }
161- TprintfT (DBG_LT1, "collector_module_init: %d modules\n", nmodules);
162+ next_init (col_intf);
163+ TprintfT (DBG_LT1, "collector_module_init: %d modules\n", next_init ? 1 : 0);
164 }
165
166 /* Routines concerned with general experiment start and stop */
167@@ -1784,7 +1779,7 @@ __collector_pause ()
168 }
169
170 void
171-__collector_pause_m (char *reason)
172+__collector_pause_m (const char *reason)
173 {
174 hrtime_t now;
175 char xreason[MAXPATHLEN];
176@@ -2451,8 +2446,8 @@ __collector_dlog (int tflag, int level, char *format, ...)
177
178 static void (*__real__exit) (int status) = NULL; /* libc only: _exit */
179 static void (*__real__Exit) (int status) = NULL; /* libc only: _Exit */
180-void _exit () __attribute__ ((weak, alias ("__collector_exit")));
181-void _Exit () __attribute__ ((weak, alias ("__collector_Exit")));
182+void _exit (int status) __attribute__ ((weak, alias ("__collector_exit")));
183+void _Exit (int status) __attribute__ ((weak, alias ("__collector_Exit")));
184
185 void
186 __collector_exit (int status)
187diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h
188index 07a03bdd17a..eda68a0e4f5 100644
189--- a/gprofng/libcollector/collector.h
190+++ b/gprofng/libcollector/collector.h
191@@ -123,7 +123,7 @@ extern void __collector_terminate_expt ();
192 extern void __collector_terminate_hook ();
193 extern void __collector_sample (char *name);
194 extern void __collector_pause ();
195-extern void __collector_pause_m ();
196+extern void __collector_pause_m (const char *reason);
197 extern void __collector_resume ();
198 extern int collector_sigemt_sigaction (const struct sigaction*,
199 struct sigaction*);
200diff --git a/gprofng/libcollector/collectorAPI.c b/gprofng/libcollector/collectorAPI.c
201index 5fa6403ad49..449bbbaab65 100644
202--- a/gprofng/libcollector/collectorAPI.c
203+++ b/gprofng/libcollector/collectorAPI.c
204@@ -26,16 +26,17 @@
205 #include "collectorAPI.h"
206 #include "gp-experiment.h"
207
208-static void *__real_collector_sample = NULL;
209-static void *__real_collector_pause = NULL;
210-static void *__real_collector_resume = NULL;
211-static void *__real_collector_terminate_expt = NULL;
212-static void *__real_collector_func_load = NULL;
213-static void *__real_collector_func_unload = NULL;
214+static void (*__real_collector_sample)(const char *) = NULL;
215+static void (*__real_collector_pause)() = NULL;
216+static void (*__real_collector_resume)() = NULL;
217+static void (*__real_collector_terminate_expt)() = NULL;
218+static void (*__real_collector_func_load)(const char *, const char *,
219+ const char *, void *, int, int, Lineno *) = NULL;
220+static void (*__real_collector_func_unload)(void *) = NULL;
221
222 #define INIT_API if (init_API == 0) collectorAPI_initAPI()
223 #define NULL_PTR(x) (__real_##x == NULL)
224-#define CALL_REAL(x) (*(void(*)())__real_##x)
225+#define CALL_REAL(x) (__real_##x)
226 #define CALL_IF_REAL(x) INIT_API; if (!NULL_PTR(x)) CALL_REAL(x)
227
228 static int init_API = 0;
229diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c
230index d2a4ad0b60b..867753a22ec 100644
231--- a/gprofng/libcollector/dispatcher.c
232+++ b/gprofng/libcollector/dispatcher.c
233@@ -909,8 +909,9 @@ sigset (int sig, sighandler_t handler)
234
235 // map interposed symbol versions
236 static int
237-gprofng_timer_create (int (real_func) (), clockid_t clockid,
238- struct sigevent *sevp, timer_t *timerid)
239+gprofng_timer_create (int (real_func) (clockid_t, struct sigevent *, timer_t *),
240+ clockid_t clockid,
241+ struct sigevent *sevp, timer_t *timerid)
242 {
243 // collector reserves SIGPROF
244 if (sevp == NULL || sevp->sigev_notify != SIGEV_SIGNAL ||
245@@ -1045,7 +1046,7 @@ __collector_thr_sigsetmask (int how, const sigset_t* iset, sigset_t* oset)
246 // map interposed symbol versions
247
248 static int
249-gprofng_pthread_sigmask (int (real_func) (),
250+gprofng_pthread_sigmask (int (real_func) (int, const sigset_t *, sigset_t*),
251 int how, const sigset_t *iset, sigset_t* oset)
252 {
253 sigset_t lsigset;
254@@ -1140,9 +1141,10 @@ collector_root (void *cargs)
255 // map interposed symbol versions
256
257 static int
258-gprofng_pthread_create (int (real_func) (), pthread_t *thread,
259- const pthread_attr_t *attr,
260- void *(*func)(void*), void *arg)
261+gprofng_pthread_create (int (real_func) (pthread_t *, const pthread_attr_t *,
262+ void *(*)(void *), void *),
263+ pthread_t *thread, const pthread_attr_t *attr,
264+ void *(*func)(void*), void *arg)
265 {
266 TprintfT (DBG_LTT, "gprofng_pthread_create @%p\n", real_func);
267 if (dispatch_mode != DISPATCH_ON)
268@@ -1277,6 +1279,7 @@ __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags,
269 }
270
271 // weak symbols:
272-int sigprocmask () __attribute__ ((weak, alias ("__collector_sigprocmask")));
273-int thr_sigsetmask () __attribute__ ((weak, alias ("__collector_thr_sigsetmask")));
274+int sigprocmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_sigprocmask")));
275+int thr_sigsetmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_thr_sigsetmask")));
276 int setitimer () __attribute__ ((weak, alias ("_setitimer")));
277+
278diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c
279index 18060864796..3deb441d9c7 100644
280--- a/gprofng/libcollector/iotrace.c
281+++ b/gprofng/libcollector/iotrace.c
282@@ -1350,7 +1350,7 @@ mkstemp (char *template)
283 unsigned pktSize;
284 if (NULL_PTR (mkstemp))
285 init_io_intf ();
286- if (CHCK_REENTRANCE (guard) || template == NULL)
287+ if (CHCK_REENTRANCE (guard))
288 return CALL_REAL (mkstemp)(template);
289 PUSH_REENTRANCE (guard);
290 hrtime_t reqt = gethrtime ();
291@@ -1405,7 +1405,7 @@ mkstemps (char *template, int slen)
292 unsigned pktSize;
293 if (NULL_PTR (mkstemps))
294 init_io_intf ();
295- if (CHCK_REENTRANCE (guard) || template == NULL)
296+ if (CHCK_REENTRANCE (guard))
297 return CALL_REAL (mkstemps)(template, slen);
298 PUSH_REENTRANCE (guard);
299 hrtime_t reqt = gethrtime ();
300@@ -1485,7 +1485,7 @@ close (int fildes)
301
302 /*------------------------------------------------------------- fopen */
303 static FILE*
304-gprofng_fopen (FILE*(real_fopen) (), const char *filename, const char *mode)
305+gprofng_fopen (FILE*(real_fopen) (const char *, const char *), const char *filename, const char *mode)
306 {
307 int *guard;
308 FILE *fp = NULL;
309@@ -1559,7 +1559,7 @@ DCL_FOPEN (fopen)
310
311 /*------------------------------------------------------------- fclose */
312 static int
313-gprofng_fclose (int(real_fclose) (), FILE *stream)
314+gprofng_fclose (int(real_fclose) (FILE *), FILE *stream)
315 {
316 int *guard;
317 int stat;
318@@ -1645,7 +1645,7 @@ fflush (FILE *stream)
319
320 /*------------------------------------------------------------- fdopen */
321 static FILE*
322-gprofng_fdopen (FILE*(real_fdopen) (), int fildes, const char *mode)
323+gprofng_fdopen (FILE*(real_fdopen) (int, const char *), int fildes, const char *mode)
324 {
325 int *guard;
326 FILE *fp = NULL;
327@@ -2957,7 +2957,7 @@ DCL_FGETPOS (fgetpos)
328
329 /*------------------------------------------------------------- fgetpos64 */
330 static int
331-gprofng_fgetpos64 (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos)
332+gprofng_fgetpos64 (int(real_fgetpos64) (FILE *, fpos64_t *), FILE *stream, fpos64_t *pos)
333 {
334 int *guard;
335 int ret;
336diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c
337index 15ba24d2ab5..c2b82894e6b 100644
338--- a/gprofng/libcollector/libcol_util.c
339+++ b/gprofng/libcollector/libcol_util.c
340@@ -1013,7 +1013,6 @@ __collector_open (const char *path, int oflag, ...)
341 mode_t mode = 0;
342
343 hrtime_t t_timeout = __collector_gethrtime () + 5 * ((hrtime_t) NANOSEC);
344- int nretries = 0;
345 long long delay = 100; /* start at some small, arbitrary value */
346
347 /* get optional mode argument if it's expected/required */
348@@ -1058,7 +1057,6 @@ __collector_open (const char *path, int oflag, ...)
349 delay *= 2;
350 if (delay > 100000000)
351 delay = 100000000; /* cap at some large, arbitrary value */
352- nretries++;
353 }
354 return fd;
355 }
356diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libcol_util.h
357index 2eeeaeed50b..1b1b928180a 100644
358--- a/gprofng/libcollector/libcol_util.h
359+++ b/gprofng/libcollector/libcol_util.h
360@@ -81,12 +81,6 @@ extern int __collector_mutex_trylock (collector_mutex_t *mp);
361 #define __collector_mutex_init(xx) \
362 do { collector_mutex_t tmp=COLLECTOR_MUTEX_INITIALIZER; *(xx)=tmp; } while(0)
363
364-void __collector_sample (char *name);
365-void __collector_terminate_expt ();
366-void __collector_pause ();
367-void __collector_pause_m ();
368-void __collector_resume ();
369-
370 struct DT_lineno;
371
372 typedef enum
373diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c
374index 67b2d7e9030..66844bc1337 100644
375--- a/gprofng/libcollector/linetrace.c
376+++ b/gprofng/libcollector/linetrace.c
377@@ -1207,7 +1207,7 @@ __collector_vfork (void)
378 }
379
380 /*------------------------------------------------------------- execve */
381-int execve () __attribute__ ((weak, alias ("__collector_execve")));
382+int execve (const char *, char *const [], char *const []) __attribute__ ((weak, alias ("__collector_execve")));
383
384 int
385 __collector_execve (const char* path, char *const argv[], char *const envp[])
386@@ -1237,7 +1237,7 @@ __collector_execve (const char* path, char *const argv[], char *const envp[])
387 return ret;
388 }
389
390-int execvp () __attribute__ ((weak, alias ("__collector_execvp")));
391+int execvp (const char *, char *const []) __attribute__ ((weak, alias ("__collector_execvp")));
392
393 int
394 __collector_execvp (const char* file, char *const argv[])
395@@ -1269,7 +1269,7 @@ __collector_execvp (const char* file, char *const argv[])
396 return ret;
397 }
398
399-int execv () __attribute__ ((weak, alias ("__collector_execv")));
400+int execv (const char *, char *const []) __attribute__ ((weak, alias ("__collector_execv")));
401
402 int
403 __collector_execv (const char* path, char *const argv[])
404@@ -1408,7 +1408,10 @@ __collector_execl (const char* path, const char *arg0, ...)
405 /*-------------------------------------------------------- posix_spawn */
406 // map interposed symbol versions
407 static int
408-gprofng_posix_spawn (int(real_posix_spawn) (),
409+gprofng_posix_spawn (int(real_posix_spawn) (pid_t *, const char *,
410+ const posix_spawn_file_actions_t *,
411+ const posix_spawnattr_t *,
412+ char *const [], char *const []),
413 pid_t *pidp, const char *path,
414 const posix_spawn_file_actions_t *file_actions,
415 const posix_spawnattr_t *attrp,
416@@ -1466,7 +1469,10 @@ DCL_POSIX_SPAWN (posix_spawn)
417
418 /*-------------------------------------------------------- posix_spawnp */
419 static int
420-gprofng_posix_spawnp (int (real_posix_spawnp) (),
421+gprofng_posix_spawnp (int (real_posix_spawnp) (pid_t *, const char *,
422+ const posix_spawn_file_actions_t *,
423+ const posix_spawnattr_t *,
424+ char *const [], char *const []),
425 pid_t *pidp, const char *path,
426 const posix_spawn_file_actions_t *file_actions,
427 const posix_spawnattr_t *attrp,
428@@ -1754,8 +1760,8 @@ __collector_clone (int (*fn)(void *), void *child_stack, int flags, void *arg,
429 }
430
431 /*-------------------------------------------------------------------- setuid */
432-int setuid () __attribute__ ((weak, alias ("__collector_setuid")));
433-int _setuid () __attribute__ ((weak, alias ("__collector_setuid")));
434+int setuid (uid_t) __attribute__ ((weak, alias ("__collector_setuid")));
435+int _setuid (uid_t) __attribute__ ((weak, alias ("__collector_setuid")));
436
437 int
438 __collector_setuid (uid_t ruid)
439@@ -1770,8 +1776,8 @@ __collector_setuid (uid_t ruid)
440 }
441
442 /*------------------------------------------------------------------- seteuid */
443-int seteuid () __attribute__ ((weak, alias ("__collector_seteuid")));
444-int _seteuid () __attribute__ ((weak, alias ("__collector_seteuid")));
445+int seteuid (uid_t) __attribute__ ((weak, alias ("__collector_seteuid")));
446+int _seteuid (uid_t) __attribute__ ((weak, alias ("__collector_seteuid")));
447
448 int
449 __collector_seteuid (uid_t euid)
450@@ -1786,8 +1792,8 @@ __collector_seteuid (uid_t euid)
451 }
452
453 /*------------------------------------------------------------------ setreuid */
454-int setreuid () __attribute__ ((weak, alias ("__collector_setreuid")));
455-int _setreuid () __attribute__ ((weak, alias ("__collector_setreuid")));
456+int setreuid (uid_t, uid_t) __attribute__ ((weak, alias ("__collector_setreuid")));
457+int _setreuid (uid_t, uid_t) __attribute__ ((weak, alias ("__collector_setreuid")));
458
459 int
460 __collector_setreuid (uid_t ruid, uid_t euid)
461@@ -1802,8 +1808,8 @@ __collector_setreuid (uid_t ruid, uid_t euid)
462 }
463
464 /*-------------------------------------------------------------------- setgid */
465-int setgid () __attribute__ ((weak, alias ("__collector_setgid")));
466-int _setgid () __attribute__ ((weak, alias ("__collector_setgid")));
467+int setgid (gid_t) __attribute__ ((weak, alias ("__collector_setgid")));
468+int _setgid (gid_t) __attribute__ ((weak, alias ("__collector_setgid")));
469
470 int
471 __collector_setgid (gid_t rgid)
472@@ -1818,8 +1824,8 @@ __collector_setgid (gid_t rgid)
473 }
474
475 /*------------------------------------------------------------------- setegid */
476-int setegid () __attribute__ ((weak, alias ("__collector_setegid")));
477-int _setegid () __attribute__ ((weak, alias ("__collector_setegid")));
478+int setegid (gid_t) __attribute__ ((weak, alias ("__collector_setegid")));
479+int _setegid (gid_t) __attribute__ ((weak, alias ("__collector_setegid")));
480
481 int
482 __collector_setegid (gid_t egid)
483@@ -1834,8 +1840,8 @@ __collector_setegid (gid_t egid)
484 }
485
486 /*------------------------------------------------------------------ setregid */
487-int setregid () __attribute__ ((weak, alias ("__collector_setregid")));
488-int _setregid () __attribute__ ((weak, alias ("__collector_setregid")));
489+int setregid (gid_t, gid_t) __attribute__ ((weak, alias ("__collector_setregid")));
490+int _setregid (gid_t, gid_t) __attribute__ ((weak, alias ("__collector_setregid")));
491
492 int
493 __collector_setregid (gid_t rgid, gid_t egid)
494diff --git a/gprofng/src/BaseMetricTreeNode.h b/gprofng/src/BaseMetricTreeNode.h
495index d73d244e27e..7698f9c6eaf 100644
496--- a/gprofng/src/BaseMetricTreeNode.h
497+++ b/gprofng/src/BaseMetricTreeNode.h
498@@ -85,7 +85,6 @@ private:
499
500 BaseMetricTreeNode *root; // root of tree
501 BaseMetricTreeNode *parent; // my parent
502- bool aggregation; // value is based on children's values
503 char *name; // bm->get_cmd() for metrics, unique string otherwise
504 char *uname; // user-visible text
505 char *unit; // see UNIT_* defines
506diff --git a/gprofng/src/Dbe.cc b/gprofng/src/Dbe.cc
507index 91a5aa5ef05..bcbf4694565 100644
508--- a/gprofng/src/Dbe.cc
509+++ b/gprofng/src/Dbe.cc
510@@ -9594,14 +9594,12 @@ dbeGetTLDataRepVals (VMode view_mode, hrtime_t start_ts, hrtime_t delta,
511 }
512 if (sampleVals != NULL)
513 {
514- Sample* sample = (Sample*) packets->getObjValue (PROP_SMPLOBJ, packetIdx);
515- if (!sample || !sample->get_usage ())
516- sample = sample;
517- else
518+ Sample *sample = (Sample*) packets->getObjValue (PROP_SMPLOBJ, packetIdx);
519+ if (sample != NULL)
520 {
521- PrUsage* prusage = sample->get_usage ();
522- Vector<long long> *mstateVals = prusage->getMstateValues ();
523- sampleVals->store (eventIdx, mstateVals);
524+ PrUsage *prusage = sample->get_usage ();
525+ if (prusage != NULL)
526+ sampleVals->store (eventIdx, prusage->getMstateValues ());
527 }
528 }
529 }
530diff --git a/gprofng/src/DbeSession.cc b/gprofng/src/DbeSession.cc
531index 20329091167..5d6bab75638 100644
532--- a/gprofng/src/DbeSession.cc
533+++ b/gprofng/src/DbeSession.cc
534@@ -1162,8 +1162,6 @@ DbeSession::open_experiment (Experiment *exp, char *path)
535 closedir (exp_dir);
536 exp_names->sort (dir_name_cmp);
537 Experiment **t_exp_list = new Experiment *[exp_names->size ()];
538- int nsubexps = 0;
539-
540 for (int j = 0, jsz = exp_names->size (); j < jsz; j++)
541 {
542 t_exp_list[j] = NULL;
543@@ -1220,7 +1218,6 @@ DbeSession::open_experiment (Experiment *exp, char *path)
544 dexp->open (dpath);
545 append (dexp);
546 t_exp_list[j] = dexp;
547- nsubexps++;
548 dexp->set_clock (exp->clock);
549
550 // DbeView add_experiment() is split into two parts
551diff --git a/gprofng/src/Disasm.cc b/gprofng/src/Disasm.cc
552index 1396e4fb072..d78212cee39 100644
553--- a/gprofng/src/Disasm.cc
554+++ b/gprofng/src/Disasm.cc
555@@ -49,7 +49,6 @@ struct DisContext
556 };
557
558 static const int MAX_DISASM_STR = 2048;
559-static const int MAX_INSTR_SIZE = 8;
560
561 Disasm::Disasm (char *fname)
562 {
563diff --git a/gprofng/src/Experiment.cc b/gprofng/src/Experiment.cc
564index 02a24ebc40d..a31550aff66 100644
565--- a/gprofng/src/Experiment.cc
566+++ b/gprofng/src/Experiment.cc
567@@ -1935,8 +1935,6 @@ private:
568 }
569
570 Experiment *exp;
571- char *hostname;
572- hrtime_t time, tstamp;
573 };
574
575 void
576diff --git a/gprofng/src/HashMap.h b/gprofng/src/HashMap.h
577index 918c0dc95f9..c5fdd345ba8 100644
578--- a/gprofng/src/HashMap.h
579+++ b/gprofng/src/HashMap.h
580@@ -78,9 +78,8 @@ copy_key (uint64_t a)
581 }
582
583 template<> inline void
584-delete_key (uint64_t a)
585+delete_key (uint64_t)
586 {
587- a = a;
588 }
589
590 template<> inline int
591diff --git a/gprofng/src/IOActivity.h b/gprofng/src/IOActivity.h
592index cf462cf8d55..f3a22ada6b1 100644
593--- a/gprofng/src/IOActivity.h
594+++ b/gprofng/src/IOActivity.h
595@@ -78,7 +78,6 @@ private:
596 Hist_data *hist_data_file_all;
597 Hist_data *hist_data_vfd_all;
598 Hist_data *hist_data_callstack_all;
599- Hist_data *hist_data_callstack;
600
601 DbeView *dbev;
602 };
603diff --git a/gprofng/src/collctrl.cc b/gprofng/src/collctrl.cc
604index ebf888c5a20..b0ed66efcdc 100644
605--- a/gprofng/src/collctrl.cc
606+++ b/gprofng/src/collctrl.cc
607@@ -952,9 +952,7 @@ Coll_Ctrl::set_clkprof (const char *string, char** warn)
608 double dval = strtod (string, &endchar);
609 if (*endchar == 'm' || *endchar == 0) /* user specified milliseconds */
610 dval = dval * 1000.;
611- else if (*endchar == 'u') /* user specified microseconds */
612- dval = dval;
613- else
614+ else if (*endchar != 'u')
615 return dbe_sprintf (GTXT ("Unrecognized clock-profiling interval `%s'\n"), string);
616 nclkprof_timer = (int) (dval + 0.5);
617 }
618@@ -2901,7 +2899,7 @@ Coll_Ctrl::get (char * control)
619 }
620 if (!strncmp (control, ipc_str_javaprof, len))
621 {
622- if ((java_mode == 0))
623+ if (java_mode == 0)
624 return strdup (ipc_str_off);
625 return strdup (ipc_str_on);
626 }
627@@ -2917,7 +2915,7 @@ Coll_Ctrl::get (char * control)
628 }
629 if (!strncmp (control, ipc_str_sample_sig, len))
630 {
631- if ((sample_sig == 0))
632+ if (sample_sig == 0)
633 return strdup (ipc_str_off);
634 char *str_signal = find_signal_name (sample_sig);
635 if (str_signal != NULL)
636@@ -2951,15 +2949,15 @@ Coll_Ctrl::get (char * control)
637 }
638 if (!strncmp (control, ipc_str_iotrace, len))
639 {
640- if ((iotrace_enabled == 0))
641+ if (iotrace_enabled == 0)
642 return strdup (ipc_str_off);
643 return strdup (ipc_str_on);
644 }
645 if (!strncmp (control, ipc_str_count, len))
646 {
647- if ((count_enabled == 0))
648+ if (count_enabled == 0)
649 return strdup (ipc_str_off);
650- if ((count_enabled < 0))
651+ if (count_enabled < 0)
652 return strdup ("on\nstatic");
653 return strdup (ipc_str_on);
654 }
655diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h
656index bb48eadb9f8..ebcdbca561f 100644
657--- a/gprofng/src/collector_module.h
658+++ b/gprofng/src/collector_module.h
659@@ -40,12 +40,12 @@ struct tm;
660 * If you add any, please put it in the right place */
661 typedef struct CollectorUtilFuncs
662 {
663- int (*access)();
664+ int (*access)(const char *, int);
665 int (*atoi)(const char *nptr);
666 void *(*calloc)(size_t nelem, size_t elsize);
667 int (*clearenv)(void);
668 int (*close)(int);
669- int (*closedir)();
670+ int (*closedir)(DIR *);
671 int (*execv)(const char *path, char *const argv[]);
672 void (*exit)(int status);
673 int (*fclose)(FILE *stream);
674@@ -66,20 +66,20 @@ typedef struct CollectorUtilFuncs
675 off_t (*lseek)(int fd, off_t offset, int whence);
676 void *(*malloc)(size_t size);
677 void *(*memset)(void *s1, int c, size_t n);
678- int (*mkdir)();
679+ int (*mkdir)(const char *, mode_t);
680 time_t (*mktime)(struct tm *timeptr);
681 void *(*mmap)(void *, size_t, int, int, int, off_t);
682- void *(*mmap64_)();
683- int (*munmap)();
684+ void *(*mmap64_)(void *, size_t, int, int, int, off_t);
685+ int (*munmap)(void *, size_t);
686 int (*open)(const char *, int, ...);
687 int (*open_bare)(const char *, int, ...);
688- DIR *(*opendir)();
689+ DIR *(*opendir)(const char *);
690 int (*pclose)(FILE *stream);
691 FILE *(*popen)(const char *command, const char *mode);
692 int (*putenv)(char *string);
693- ssize_t (*pwrite)();
694- ssize_t (*pwrite64_)();
695- ssize_t (*read)();
696+ ssize_t (*pwrite)(int, const void *, size_t, off_t);
697+ ssize_t (*pwrite64_)(int, const void *, size_t, off_t);
698+ ssize_t (*read)(int, void *, size_t);
699 int (*setenv)(const char *name, const char *value, int overwrite);
700 int (*sigfillset)(sigset_t *set);
701 int (*sigprocmask)(int how, const sigset_t *set, sigset_t *oldset);
702@@ -112,7 +112,7 @@ typedef struct CollectorUtilFuncs
703 int (*unsetenv)(const char *name);
704 int (*vsnprintf)(char *str, size_t size, const char *format, va_list ap);
705 pid_t (*waitpid)(pid_t pid, int *stat_loc, int options);
706- ssize_t (*write)();
707+ ssize_t (*write)(int, void *, size_t);
708 double (*atof)();
709 void *n_a;
710 } CollectorUtilFuncs;
711diff --git a/gprofng/src/gp-display-src.cc b/gprofng/src/gp-display-src.cc
712index 200e6080d2e..24af375edf1 100644
713--- a/gprofng/src/gp-display-src.cc
714+++ b/gprofng/src/gp-display-src.cc
715@@ -75,14 +75,6 @@ private:
716 bool v_opt;
717 int multiple;
718 char *str_compcom;
719- bool hex_visible;
720- int src_visible;
721- int vis_src;
722- int vis_dis;
723- int threshold_src;
724- int threshold_dis;
725- int threshold;
726- int vis_bits;
727 };
728
729 static int
730diff --git a/gprofng/src/gp-print.h b/gprofng/src/gp-print.h
731index 1b748ea60a3..1a8ad3b6c13 100644
732--- a/gprofng/src/gp-print.h
733+++ b/gprofng/src/gp-print.h
734@@ -19,7 +19,7 @@
735 MA 02110-1301, USA. */
736
737 #ifndef _GP_PRINT_H
738-#define _ER_PRINT_H
739+#define _GP_PRINT_H
740
741 #include "Command.h"
742 #include "DbeApplication.h"
743diff --git a/gprofng/src/util.cc b/gprofng/src/util.cc
744index 201f7088b66..228140b61ae 100644
745--- a/gprofng/src/util.cc
746+++ b/gprofng/src/util.cc
747@@ -741,17 +741,13 @@ get_relative_link (const char *path_from, const char *path_to)
748 s2 = canonical_path (s2);
749 long l = dbe_sstrlen (s1);
750 // try to find common directories
751- int common_slashes = 0;
752 int last_common_slash = -1;
753 for (int i = 0; i < l; i++)
754 {
755- if (s1[i] != s2[i]) break;
756- if (s1[i] == 0) break;
757+ if (s1[i] != s2[i] || s1[i] == 0)
758+ break;
759 if (s1[i] == '/')
760- {
761- common_slashes++;
762- last_common_slash = i;
763- }
764+ last_common_slash = i;
765 }
766 // find slashes in remaining path_to
767 int slashes = 0;
diff --git a/meta/recipes-devtools/binutils/binutils/0020-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch b/meta/recipes-devtools/binutils/binutils/0020-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch
new file mode 100644
index 0000000000..a1b8bb6d18
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0020-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch
@@ -0,0 +1,606 @@
1From 610889f9e0cace025758fdd0ce8e8f9edf9f4223 Mon Sep 17 00:00:00 2001
2From: Sam James <sam@gentoo.org>
3Date: Sat, 16 Nov 2024 05:13:48 +0000
4Subject: [PATCH] gprofng: fix -std=gnu23 compatibility wrt unprototyped
5 functions
6
7C23 removes support for unprototyped functions. Fix function pointer types
8accordingly.
9
10This does not fix all instances, there's a few left as I commented on in
11PR32374 (e.g. setitimer which I have a local workaround for but it involves
12a glibc implementation detail; the Linaro precommit CI tester pointed that
13out too, so dropped that).
14
15ChangeLog:
16 PR gprofng/32374
17
18 * libcollector/collector.c (collector_sample): Fix prototype.
19 * libcollector/envmgmt.c (putenv): Ditto.
20 (_putenv): Ditto.
21 (__collector_putenv): Ditto.
22 (setenv): Ditto.
23 (_setenv): Ditto.
24 (__collector_setenv): Ditto.
25 (unsetenv): Ditto.
26 (_unsetenv): Ditto.
27 (__collector_unsetenv): Ditto.
28 * libcollector/jprofile.c (open_experiment): Ditto.
29 (__collector_jprofile_enable_synctrace): Ditto.
30 (jprof_find_asyncgetcalltrace): Ditto.
31 * libcollector/libcol_util.c (__collector_util_init): Ditto.
32 (ARCH): Ditto.
33 * libcollector/mmaptrace.c (collector_func_load): Ditto.
34 (collector_func_unload): Ditto.
35 * libcollector/unwind.c (__collector_ext_unwind_init): Ditto.
36 * src/collector_module.h: Ditto.
37
38Upstream-Status: Backport [https://github.com/bminor/binutils-gdb/commit/a2f774427e078f3da2c06bdea25f77a61979a695]
39Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
40---
41 gprofng/libcollector/collector.c | 2 +-
42 gprofng/libcollector/envmgmt.c | 24 ++++-----
43 gprofng/libcollector/jprofile.c | 10 ++--
44 gprofng/libcollector/libcol_util.c | 84 +++++++++++++++---------------
45 gprofng/libcollector/mmaptrace.c | 4 +-
46 gprofng/libcollector/unwind.c | 2 +-
47 gprofng/src/collector_module.h | 2 +-
48 7 files changed, 64 insertions(+), 64 deletions(-)
49
50diff --git a/gprofng/libcollector/collector.c b/gprofng/libcollector/collector.c
51index ef580dcbdd9..899f08a5381 100644
52--- a/gprofng/libcollector/collector.c
53+++ b/gprofng/libcollector/collector.c
54@@ -1579,7 +1579,7 @@ __collector_resume_experiment ()
55 }
56
57 /* Code to support Samples and Pause/Resume */
58-void collector_sample () __attribute__ ((weak, alias ("__collector_sample")));
59+void collector_sample (char *name) __attribute__ ((weak, alias ("__collector_sample")));
60 void
61 __collector_sample (char *name)
62 {
63diff --git a/gprofng/libcollector/envmgmt.c b/gprofng/libcollector/envmgmt.c
64index ebe08f82007..0ff7621070d 100644
65--- a/gprofng/libcollector/envmgmt.c
66+++ b/gprofng/libcollector/envmgmt.c
67@@ -692,8 +692,8 @@ __collector_env_update (char *envp[])
68
69
70 /*------------------------------------------------------------- putenv */
71-int putenv () __attribute__ ((weak, alias ("__collector_putenv")));
72-int _putenv () __attribute__ ((weak, alias ("__collector_putenv")));
73+int putenv (char*) __attribute__ ((weak, alias ("__collector_putenv")));
74+int _putenv (char*) __attribute__ ((weak, alias ("__collector_putenv")));
75
76 int
77 __collector_putenv (char * string)
78@@ -701,9 +701,9 @@ __collector_putenv (char * string)
79 if (CALL_UTIL (putenv) == __collector_putenv ||
80 CALL_UTIL (putenv) == NULL)
81 { // __collector_libc_funcs_init failed
82- CALL_UTIL (putenv) = (int(*)())dlsym (RTLD_NEXT, "putenv");
83+ CALL_UTIL (putenv) = (int(*)(char*))dlsym (RTLD_NEXT, "putenv");
84 if (CALL_UTIL (putenv) == NULL || CALL_UTIL (putenv) == __collector_putenv)
85- CALL_UTIL (putenv) = (int(*)())dlsym (RTLD_DEFAULT, "putenv");
86+ CALL_UTIL (putenv) = (int(*)(char*))dlsym (RTLD_DEFAULT, "putenv");
87 if (CALL_UTIL (putenv) == NULL || CALL_UTIL (putenv) == __collector_putenv)
88 {
89 TprintfT (DBG_LT2, "__collector_putenv(): ERROR: no pointer found.\n");
90@@ -719,8 +719,8 @@ __collector_putenv (char * string)
91 }
92
93 /*------------------------------------------------------------- setenv */
94-int setenv () __attribute__ ((weak, alias ("__collector_setenv")));
95-int _setenv () __attribute__ ((weak, alias ("__collector_setenv")));
96+int setenv (const char*, const char*, int) __attribute__ ((weak, alias ("__collector_setenv")));
97+int _setenv (const char*, const char*, int) __attribute__ ((weak, alias ("__collector_setenv")));
98
99 int
100 __collector_setenv (const char *name, const char *value, int overwrite)
101@@ -728,9 +728,9 @@ __collector_setenv (const char *name, const char *value, int overwrite)
102 if (CALL_UTIL (setenv) == __collector_setenv ||
103 CALL_UTIL (setenv) == NULL)
104 { // __collector_libc_funcs_init failed
105- CALL_UTIL (setenv) = (int(*)())dlsym (RTLD_NEXT, "setenv");
106+ CALL_UTIL (setenv) = (int(*)(const char*, const char*, int))dlsym (RTLD_NEXT, "setenv");
107 if (CALL_UTIL (setenv) == NULL || CALL_UTIL (setenv) == __collector_setenv)
108- CALL_UTIL (setenv) = (int(*)())dlsym (RTLD_DEFAULT, "setenv");
109+ CALL_UTIL (setenv) = (int(*)(const char*, const char*, int))dlsym (RTLD_DEFAULT, "setenv");
110 if (CALL_UTIL (setenv) == NULL || CALL_UTIL (setenv) == __collector_setenv)
111 {
112 TprintfT (DBG_LT2, "__collector_setenv(): ERROR: no pointer found.\n");
113@@ -765,8 +765,8 @@ __collector_setenv (const char *name, const char *value, int overwrite)
114 }
115
116 /*------------------------------------------------------------- unsetenv */
117-int unsetenv () __attribute__ ((weak, alias ("__collector_unsetenv")));
118-int _unsetenv () __attribute__ ((weak, alias ("__collector_unsetenv")));
119+int unsetenv (const char*) __attribute__ ((weak, alias ("__collector_unsetenv")));
120+int _unsetenv (const char*) __attribute__ ((weak, alias ("__collector_unsetenv")));
121
122 int
123 __collector_unsetenv (const char *name)
124@@ -774,9 +774,9 @@ __collector_unsetenv (const char *name)
125 if (CALL_UTIL (unsetenv) == __collector_unsetenv ||
126 CALL_UTIL (unsetenv) == NULL)
127 { // __collector_libc_funcs_init failed
128- CALL_UTIL (unsetenv) = (int(*)())dlsym (RTLD_NEXT, "unsetenv");
129+ CALL_UTIL (unsetenv) = (int(*)(const char*))dlsym (RTLD_NEXT, "unsetenv");
130 if (CALL_UTIL (unsetenv) == NULL || CALL_UTIL (unsetenv) == __collector_unsetenv)
131- CALL_UTIL (unsetenv) = (int(*)())dlsym (RTLD_DEFAULT, "unsetenv");
132+ CALL_UTIL (unsetenv) = (int(*)(const char*))dlsym (RTLD_DEFAULT, "unsetenv");
133 if (CALL_UTIL (unsetenv) == NULL || CALL_UTIL (unsetenv) == __collector_unsetenv)
134 {
135 TprintfT (DBG_LT2, "__collector_unsetenv(): ERROR: no pointer found.\n");
136diff --git a/gprofng/libcollector/jprofile.c b/gprofng/libcollector/jprofile.c
137index 1bacacc1a2a..11051f937ef 100644
138--- a/gprofng/libcollector/jprofile.c
139+++ b/gprofng/libcollector/jprofile.c
140@@ -105,8 +105,8 @@ static void rwrite (int fd, const void *buf, size_t nbyte);
141 static void addToDynamicArchive (const char* name, const unsigned char* class_data, int class_data_len);
142 static void (*AsyncGetCallTrace)(JVMPI_CallTrace*, jint, ucontext_t*) = NULL;
143 static void (*collector_heap_record)(int, int, void*) = NULL;
144-static void (*collector_jsync_begin)() = NULL;
145-static void (*collector_jsync_end)(hrtime_t, void *) = NULL;
146+static void (*collector_jsync_begin)(void) = NULL;
147+static void (*collector_jsync_end)(hrtime_t, void*) = NULL;
148
149 #define gethrtime collector_interface->getHiResTime
150
151@@ -230,7 +230,7 @@ open_experiment (const char *exp)
152 else if (__collector_strStartWith (args, "s:") == 0)
153 {
154 java_sync_mode = 1;
155- collector_jsync_begin = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_begin");
156+ collector_jsync_begin = (void(*)(void))dlsym (RTLD_DEFAULT, "__collector_jsync_begin");
157 collector_jsync_end = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_end");
158 }
159 #endif
160@@ -255,7 +255,7 @@ __collector_jprofile_enable_synctrace ()
161 return;
162 }
163 java_sync_mode = 1;
164- collector_jsync_begin = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_begin");
165+ collector_jsync_begin = (void(*)(void))dlsym (RTLD_DEFAULT, "__collector_jsync_begin");
166 collector_jsync_end = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_end");
167 TprintfT (DBG_LT1, "jprofile: turning on Java synctrace, and requesting events\n");
168 }
169@@ -1129,7 +1129,7 @@ jprof_find_asyncgetcalltrace ()
170 {
171 void *jvmhandle;
172 if (__collector_VM_ReadByteInstruction == NULL)
173- __collector_VM_ReadByteInstruction = (int(*)()) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction");
174+ __collector_VM_ReadByteInstruction = (int(*)(unsigned char*)) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction");
175
176 /* look for stack unwind function using default path */
177 AsyncGetCallTrace = (void (*)(JVMPI_CallTrace*, jint, ucontext_t*))
178diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c
179index c2b82894e6b..688bdf19c6d 100644
180--- a/gprofng/libcollector/libcol_util.c
181+++ b/gprofng/libcollector/libcol_util.c
182@@ -1114,7 +1114,7 @@ __collector_util_init ()
183
184 ptr = dlsym (libc, "munmap");
185 if (ptr)
186- __collector_util_funcs.munmap = (int(*)())ptr;
187+ __collector_util_funcs.munmap = (int(*)(void *, size_t))ptr;
188 else
189 {
190 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT munmap: %s\n", dlerror ());
191@@ -1123,7 +1123,7 @@ __collector_util_init ()
192
193 ptr = dlsym (libc, "close");
194 if (ptr)
195- __collector_util_funcs.close = (int(*)())ptr;
196+ __collector_util_funcs.close = (int(*)(int))ptr;
197 else
198 {
199 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT close: %s\n", dlerror ());
200@@ -1158,7 +1158,7 @@ __collector_util_init ()
201
202 ptr = dlsym (libc, "close");
203 if (ptr)
204- __collector_util_funcs.close = (int(*)())ptr;
205+ __collector_util_funcs.close = (int(*)(int))ptr;
206 else
207 {
208 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT close: %s\n", dlerror ());
209@@ -1167,7 +1167,7 @@ __collector_util_init ()
210
211 ptr = dlsym (libc, "read");
212 if (ptr)
213- __collector_util_funcs.read = (ssize_t (*)())ptr;
214+ __collector_util_funcs.read = (ssize_t (*)(int, void*, size_t))ptr;
215 else
216 {
217 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT read: %s\n", dlerror ());
218@@ -1176,7 +1176,7 @@ __collector_util_init ()
219
220 ptr = dlsym (libc, "write");
221 if (ptr)
222- __collector_util_funcs.write = (ssize_t (*)())ptr;
223+ __collector_util_funcs.write = (ssize_t (*)(int, void*, size_t))ptr;
224 else
225 {
226 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT write: %s\n", dlerror ());
227@@ -1186,14 +1186,14 @@ __collector_util_init ()
228 #if ARCH(Intel) && WSIZE(32)
229 ptr = dlvsym (libc, "pwrite", "GLIBC_2.2"); // it is in /lib/libpthread.so.0
230 if (ptr)
231- __collector_util_funcs.pwrite = (ssize_t (*)())ptr;
232+ __collector_util_funcs.pwrite = (ssize_t (*)(int, void*, size_t, off_t))ptr;
233 else
234 {
235 Tprintf (DBG_LT0, "libcol_util: WARNING: dlvsym for %s@%s failed. Using dlsym() instead.", "pwrite", "GLIBC_2.2");
236 #endif /* ARCH(Intel) && WSIZE(32) */
237 ptr = dlsym (libc, "pwrite");
238 if (ptr)
239- __collector_util_funcs.pwrite = (ssize_t (*)())ptr;
240+ __collector_util_funcs.pwrite = (ssize_t (*)(int, const void*, size_t, off_t))ptr;
241 else
242 {
243 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT pwrite: %s\n", dlerror ());
244@@ -1213,7 +1213,7 @@ __collector_util_init ()
245 #endif /* ARCH(Intel) && WSIZE(32) */
246 ptr = dlsym (libc, "pwrite64");
247 if (ptr)
248- __collector_util_funcs.pwrite64_ = (ssize_t (*)())ptr;
249+ __collector_util_funcs.pwrite64_ = (ssize_t (*)(int, const void*, size_t, off_t))ptr;
250 else
251 __collector_util_funcs.pwrite64_ = __collector_util_funcs.pwrite;
252 #if ARCH(Intel) && WSIZE(32)
253@@ -1222,7 +1222,7 @@ __collector_util_init ()
254
255 ptr = dlsym (libc, "lseek");
256 if (ptr)
257- __collector_util_funcs.lseek = (off_t (*)())ptr;
258+ __collector_util_funcs.lseek = (off_t (*)(int, off_t, int))ptr;
259 else
260 {
261 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT lseek: %s\n", dlerror ());
262@@ -1231,7 +1231,7 @@ __collector_util_init ()
263
264 ptr = dlsym (libc, "access");
265 if (ptr)
266- __collector_util_funcs.access = (int(*)())ptr;
267+ __collector_util_funcs.access = (int(*)(const char*, int))ptr;
268 else
269 {
270 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT access: %s\n", dlerror ());
271@@ -1240,7 +1240,7 @@ __collector_util_init ()
272
273 ptr = dlsym (libc, "mkdir");
274 if (ptr)
275- __collector_util_funcs.mkdir = (int(*)())ptr;
276+ __collector_util_funcs.mkdir = (int(*)(const char*, mode_t))ptr;
277 else
278 {
279 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT mkdir: %s\n", dlerror ());
280@@ -1249,7 +1249,7 @@ __collector_util_init ()
281
282 ptr = dlsym (libc, "opendir");
283 if (ptr)
284- __collector_util_funcs.opendir = (DIR * (*)())ptr;
285+ __collector_util_funcs.opendir = (DIR * (*)(const char*))ptr;
286 else
287 {
288 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT opendir: %s\n", dlerror ());
289@@ -1258,7 +1258,7 @@ __collector_util_init ()
290
291 ptr = dlsym (libc, "closedir");
292 if (ptr)
293- __collector_util_funcs.closedir = (int(*)())ptr;
294+ __collector_util_funcs.closedir = (int(*)(DIR*))ptr;
295 else
296 {
297 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT closedir: %s\n", dlerror ());
298@@ -1267,7 +1267,7 @@ __collector_util_init ()
299
300 ptr = dlsym (libc, "execv");
301 if (ptr)
302- __collector_util_funcs.execv = (int(*)())ptr;
303+ __collector_util_funcs.execv = (int(*)(const char*, char* const*))ptr;
304 else
305 {
306 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT execv: %s\n", dlerror ());
307@@ -1276,7 +1276,7 @@ __collector_util_init ()
308
309 ptr = dlsym (libc, "exit");
310 if (ptr)
311- __collector_util_funcs.exit = (void(*)())ptr;
312+ __collector_util_funcs.exit = (void(*)(int))ptr;
313 else
314 {
315 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT exit: %s\n", dlerror ());
316@@ -1285,7 +1285,7 @@ __collector_util_init ()
317
318 ptr = dlsym (libc, "vfork");
319 if (ptr)
320- __collector_util_funcs.vfork = (pid_t (*)())ptr;
321+ __collector_util_funcs.vfork = (pid_t (*)(void))ptr;
322 else
323 {
324 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT vfork: %s\n", dlerror ());
325@@ -1294,7 +1294,7 @@ __collector_util_init ()
326
327 ptr = dlsym (libc, "waitpid");
328 if (ptr)
329- __collector_util_funcs.waitpid = (pid_t (*)())ptr;
330+ __collector_util_funcs.waitpid = (pid_t (*)(pid_t, int*, int))ptr;
331 else
332 {
333 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT waitpid: %s\n", dlerror ());
334@@ -1313,7 +1313,7 @@ __collector_util_init ()
335
336 ptr = dlsym (libc, "getcontext");
337 if (ptr)
338- __collector_util_funcs.getcontext = (int(*)())ptr;
339+ __collector_util_funcs.getcontext = (int(*)(ucontext_t*))ptr;
340 else
341 {
342 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT getcontext: %s\n", dlerror ());
343@@ -1331,7 +1331,7 @@ __collector_util_init ()
344
345 ptr = dlsym (libc, "putenv");
346 if (ptr)
347- __collector_util_funcs.putenv = (int(*)())ptr;
348+ __collector_util_funcs.putenv = (int(*)(char*))ptr;
349 else
350 {
351 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT putenv: %s\n", dlerror ());
352@@ -1340,7 +1340,7 @@ __collector_util_init ()
353
354 ptr = dlsym (libc, "getenv");
355 if (ptr)
356- __collector_util_funcs.getenv = (char*(*)())ptr;
357+ __collector_util_funcs.getenv = (char*(*)(const char*))ptr;
358 else
359 {
360 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT getenv: %s\n", dlerror ());
361@@ -1349,7 +1349,7 @@ __collector_util_init ()
362
363 ptr = dlsym (libc, "time");
364 if (ptr)
365- __collector_util_funcs.time = (time_t (*)())ptr;
366+ __collector_util_funcs.time = (time_t (*)(time_t*))ptr;
367 else
368 {
369 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT time: %s\n", dlerror ());
370@@ -1358,7 +1358,7 @@ __collector_util_init ()
371
372 ptr = dlsym (libc, "mktime");
373 if (ptr)
374- __collector_util_funcs.mktime = (time_t (*)())ptr;
375+ __collector_util_funcs.mktime = (time_t (*)(struct tm*))ptr;
376 else
377 {
378 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT mktime: %s\n", dlerror ());
379@@ -1372,7 +1372,7 @@ __collector_util_init ()
380
381 ptr = dlsym (libc, "gmtime_r");
382 if (ptr)
383- __collector_util_funcs.gmtime_r = (struct tm * (*)())ptr;
384+ __collector_util_funcs.gmtime_r = (struct tm * (*)(const time_t*, struct tm*))ptr;
385 else
386 {
387 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT gmtime_r: %s\n", dlerror ());
388@@ -1381,7 +1381,7 @@ __collector_util_init ()
389
390 ptr = dlsym (libc, "strtol");
391 if (ptr)
392- __collector_util_funcs.strtol = (long (*)())ptr;
393+ __collector_util_funcs.strtol = (long (*)(const char*, char**, int))ptr;
394 else
395 {
396 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtol: %s\n", dlerror ());
397@@ -1390,7 +1390,7 @@ __collector_util_init ()
398
399 ptr = dlsym (libc, "strtoll");
400 if (ptr)
401- __collector_util_funcs.strtoll = (long long (*)())ptr;
402+ __collector_util_funcs.strtoll = (long long (*)(const char*, char**, int))ptr;
403 else
404 {
405 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtoll: %s\n", dlerror ());
406@@ -1402,7 +1402,7 @@ __collector_util_init ()
407
408 ptr = dlsym (libc, "setenv");
409 if (ptr)
410- __collector_util_funcs.setenv = (int(*)())ptr;
411+ __collector_util_funcs.setenv = (int(*)(const char*, const char*, int))ptr;
412 else
413 {
414 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT setenv: %s\n", dlerror ());
415@@ -1411,7 +1411,7 @@ __collector_util_init ()
416
417 ptr = dlsym (libc, "unsetenv");
418 if (ptr)
419- __collector_util_funcs.unsetenv = (int(*)())ptr;
420+ __collector_util_funcs.unsetenv = (int(*)(const char*))ptr;
421 else
422 {
423 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT unsetenv: %s\n", dlerror ());
424@@ -1498,7 +1498,7 @@ __collector_util_init ()
425
426 ptr = dlsym (libc, "pclose");
427 if (ptr)
428- __collector_util_funcs.pclose = (int(*)())ptr;
429+ __collector_util_funcs.pclose = (int(*)(FILE*))ptr;
430 else
431 {
432 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT pclose: %s\n", dlerror ());
433@@ -1507,7 +1507,7 @@ __collector_util_init ()
434
435 ptr = dlsym (libc, "fgets");
436 if (ptr)
437- __collector_util_funcs.fgets = (char*(*)())ptr;
438+ __collector_util_funcs.fgets = (char*(*)(char*, int, FILE*))ptr;
439 else
440 {
441 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT fgets: %s\n", dlerror ());
442@@ -1534,7 +1534,7 @@ __collector_util_init ()
443
444 ptr = dlsym (libc, "vsnprintf");
445 if (ptr)
446- __collector_util_funcs.vsnprintf = (int(*)())ptr;
447+ __collector_util_funcs.vsnprintf = (int(*)(char*, size_t, const char*, ...))ptr;
448 else
449 {
450 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT vsnprintf: %s\n", dlerror ());
451@@ -1543,7 +1543,7 @@ __collector_util_init ()
452
453 ptr = dlsym (libc, "atoi");
454 if (ptr)
455- __collector_util_funcs.atoi = (int(*)())ptr;
456+ __collector_util_funcs.atoi = (int(*)(const char*))ptr;
457 else
458 {
459 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT atoi: %s\n", dlerror ());
460@@ -1552,7 +1552,7 @@ __collector_util_init ()
461
462 ptr = dlsym (libc, "calloc");
463 if (ptr)
464- __collector_util_funcs.calloc = (void*(*)())ptr;
465+ __collector_util_funcs.calloc = (void*(*)(size_t, size_t))ptr;
466 else
467 {
468 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT calloc: %s\n", dlerror ());
469@@ -1562,7 +1562,7 @@ __collector_util_init ()
470 ptr = dlsym (libc, "free");
471 if (ptr)
472 {
473- __collector_util_funcs.free = (void(*)())ptr;
474+ __collector_util_funcs.free = (void(*)(void*))ptr;
475 }
476 else
477 {
478@@ -1572,7 +1572,7 @@ __collector_util_init ()
479
480 ptr = dlsym (libc, "strdup");
481 if (ptr)
482- __collector_util_funcs.libc_strdup = (char*(*)())ptr;
483+ __collector_util_funcs.libc_strdup = (char*(*)(const char*))ptr;
484 else
485 {
486 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strdup: %s\n", dlerror ());
487@@ -1585,7 +1585,7 @@ __collector_util_init ()
488
489 ptr = dlsym (libc, "strerror");
490 if (ptr)
491- __collector_util_funcs.strerror = (char*(*)())ptr;
492+ __collector_util_funcs.strerror = (char*(*)(int))ptr;
493 else
494 {
495 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strerror: %s\n", dlerror ());
496@@ -1593,7 +1593,7 @@ __collector_util_init ()
497 }
498 ptr = dlsym (libc, "strerror_r");
499 if (ptr)
500- __collector_util_funcs.strerror_r = (int(*)())ptr;
501+ __collector_util_funcs.strerror_r = (int(*)(int, char*, size_t))ptr;
502 else
503 {
504 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strerror_r: %s\n", dlerror ());
505@@ -1601,7 +1601,7 @@ __collector_util_init ()
506 }
507 ptr = dlsym (libc, "strspn");
508 if (ptr)
509- __collector_util_funcs.strspn = (size_t (*)())ptr;
510+ __collector_util_funcs.strspn = (size_t (*)(const char*, const char*))ptr;
511 else
512 {
513 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strspn: %s\n", dlerror ());
514@@ -1610,7 +1610,7 @@ __collector_util_init ()
515
516 ptr = dlsym (libc, "strtoul");
517 if (ptr)
518- __collector_util_funcs.strtoul = (unsigned long int(*)())ptr;
519+ __collector_util_funcs.strtoul = (unsigned long int(*)(const char*, char**, int))ptr;
520 else
521 {
522 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtoul: %s\n", dlerror ());
523@@ -1619,7 +1619,7 @@ __collector_util_init ()
524
525 ptr = dlsym (libc, "strtoull");
526 if (ptr)
527- __collector_util_funcs.strtoull = (unsigned long long int(*)())ptr;
528+ __collector_util_funcs.strtoull = (unsigned long long int(*)(const char*, char**, int))ptr;
529 else
530 {
531 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtoull: %s\n", dlerror ());
532@@ -1664,7 +1664,7 @@ __collector_util_init ()
533
534 ptr = dlsym (libc, "sysconf");
535 if (ptr)
536- __collector_util_funcs.sysconf = (long(*)())ptr;
537+ __collector_util_funcs.sysconf = (long(*)(int))ptr;
538 else
539 {
540 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sysconf: %s\n", dlerror ());
541@@ -1673,7 +1673,7 @@ __collector_util_init ()
542
543 ptr = dlsym (libc, "sigfillset");
544 if (ptr)
545- __collector_util_funcs.sigfillset = (int(*)())ptr;
546+ __collector_util_funcs.sigfillset = (int(*)(sigset_t*))ptr;
547 else
548 {
549 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sigfillset: %s\n", dlerror ());
550@@ -1682,7 +1682,7 @@ __collector_util_init ()
551
552 ptr = dlsym (libc, "sigprocmask");
553 if (ptr)
554- __collector_util_funcs.sigprocmask = (int(*)())ptr;
555+ __collector_util_funcs.sigprocmask = (int(*)(int, const sigset_t*, sigset_t*))ptr;
556 else
557 {
558 CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sigprocmask: %s\n", dlerror ());
559diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c
560index f07f4d76513..2a6857ab58e 100644
561--- a/gprofng/libcollector/mmaptrace.c
562+++ b/gprofng/libcollector/mmaptrace.c
563@@ -1209,7 +1209,7 @@ process_vsyscall_page ()
564 /*
565 * collector API for dynamic functions
566 */
567-void collector_func_load () __attribute__ ((weak, alias ("__collector_func_load")));
568+void collector_func_load (char*, char*, char*, void*, int, int, DT_lineno *) __attribute__ ((weak, alias ("__collector_func_load")));
569 void
570 __collector_func_load (char *name, char *alias, char *sourcename,
571 void *vaddr, int size, int lntsize, DT_lineno *lntable)
572@@ -1218,7 +1218,7 @@ __collector_func_load (char *name, char *alias, char *sourcename,
573 vaddr, size, lntsize, lntable);
574 }
575
576-void collector_func_unload () __attribute__ ((weak, alias ("__collector_func_unload")));
577+void collector_func_unload (void *vaddr) __attribute__ ((weak, alias ("__collector_func_unload")));
578 void
579 __collector_func_unload (void *vaddr)
580 {
581diff --git a/gprofng/libcollector/unwind.c b/gprofng/libcollector/unwind.c
582index 91678b1e334..cd47d4fbe0f 100644
583--- a/gprofng/libcollector/unwind.c
584+++ b/gprofng/libcollector/unwind.c
585@@ -416,7 +416,7 @@ __collector_ext_unwind_init (int record)
586 omp_no_walk = 1;
587
588 if (__collector_VM_ReadByteInstruction == NULL)
589- __collector_VM_ReadByteInstruction = (int(*)()) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction");
590+ __collector_VM_ReadByteInstruction = (int(*)(unsigned char*)) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction");
591
592 #if ARCH(SPARC)
593 #if WSIZE(64)
594diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h
595index ebcdbca561f..fd888cd58dd 100644
596--- a/gprofng/src/collector_module.h
597+++ b/gprofng/src/collector_module.h
598@@ -110,7 +110,7 @@ typedef struct CollectorUtilFuncs
599 long (*sysinfo)(int command, char *buf, long count);
600 time_t (*time)(time_t *tloc);
601 int (*unsetenv)(const char *name);
602- int (*vsnprintf)(char *str, size_t size, const char *format, va_list ap);
603+ int (*vsnprintf)(char *str, size_t size, const char *format, ...);
604 pid_t (*waitpid)(pid_t pid, int *stat_loc, int options);
605 ssize_t (*write)(int, void *, size_t);
606 double (*atof)();
diff --git a/meta/recipes-devtools/binutils/binutils/0021-gprofng-fix-build-with-std-gnu23.patch b/meta/recipes-devtools/binutils/binutils/0021-gprofng-fix-build-with-std-gnu23.patch
new file mode 100644
index 0000000000..8a465bce00
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0021-gprofng-fix-build-with-std-gnu23.patch
@@ -0,0 +1,196 @@
1From 7683ea4411d2b76f346a8100b761615d09343448 Mon Sep 17 00:00:00 2001
2From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
3Date: Thu, 21 Nov 2024 14:48:20 -0800
4Subject: [PATCH] gprofng: fix build with -std=gnu23
5
6Fix function pointer types accordingly.
7Remove unused function pointers.
8
9gprofng/ChangeLog
102024-11-21 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
11
12 PR gprofng/32374
13 PR gprofng/32373
14 * common/cpuid.c: Define ATTRIBUTE_UNUSED if necessary.
15 * libcollector/libcol_util.c (sysinfo): Remove unused pointer.
16 * src/collector_module.h: Likewise.
17 * libcollector/dispatcher.c (setitimer): Fix prototype.
18 * libcollector/linetrace.c (system, grantpt, ptsname): Likewise.
19 * testsuite/gprofng.display/mttest/mttest.c (dump_arrays): Likewise.
20 * testsuite/gprofng.display/synprog/endcases.c (xinline_code,
21 s_inline_code): Likewise.
22 * testsuite/gprofng.display/synprog/inc_inline.h (ext_inline_code):
23 Likewise.
24 * testsuite/gprofng.display/synprog/synprog.c (doabort): Rename nullptr.
25Upstream-Status: Backport [https://github.com/bminor/binutils-gdb/commit/4e943705e3e8a5a9448d087502bcb390a694ad02]
26Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
27---
28 gprofng/common/cpuid.c | 2 ++
29 gprofng/libcollector/dispatcher.c | 3 +--
30 gprofng/libcollector/libcol_util.c | 9 ---------
31 gprofng/libcollector/linetrace.c | 10 +++++-----
32 gprofng/src/collector_module.h | 1 -
33 gprofng/testsuite/gprofng.display/mttest/mttest.c | 2 +-
34 gprofng/testsuite/gprofng.display/synprog/endcases.c | 4 ++--
35 gprofng/testsuite/gprofng.display/synprog/inc_inline.h | 2 +-
36 gprofng/testsuite/gprofng.display/synprog/synprog.c | 4 ++--
37 9 files changed, 14 insertions(+), 23 deletions(-)
38
39diff --git a/gprofng/common/cpuid.c b/gprofng/common/cpuid.c
40index af15439eb27..0373969693b 100644
41--- a/gprofng/common/cpuid.c
42+++ b/gprofng/common/cpuid.c
43@@ -21,7 +21,9 @@
44 #if defined(__i386__) || defined(__x86_64)
45 #include <cpuid.h> /* GCC-provided */
46 #elif defined(__aarch64__)
47+#if !defined(ATTRIBUTE_UNUSED)
48 #define ATTRIBUTE_UNUSED __attribute__((unused))
49+#endif
50
51 static inline uint_t __attribute_const__
52 __get_cpuid (unsigned int op ATTRIBUTE_UNUSED, unsigned int *eax,
53diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c
54index 867753a22ec..e85c343c776 100644
55--- a/gprofng/libcollector/dispatcher.c
56+++ b/gprofng/libcollector/dispatcher.c
57@@ -1281,5 +1281,4 @@ __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags,
58 // weak symbols:
59 int sigprocmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_sigprocmask")));
60 int thr_sigsetmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_thr_sigsetmask")));
61-int setitimer () __attribute__ ((weak, alias ("_setitimer")));
62-
63+__typeof(setitimer) setitimer __attribute__ ((weak, alias ("_setitimer")));
64diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c
65index 688bdf19c6d..46f8b80ccb4 100644
66--- a/gprofng/libcollector/libcol_util.c
67+++ b/gprofng/libcollector/libcol_util.c
68@@ -1427,15 +1427,6 @@ __collector_util_init ()
69 err = COL_ERROR_UTIL_INIT;
70 }
71
72- ptr = dlsym (libc, "sysinfo");
73- if (ptr)
74- __collector_util_funcs.sysinfo = (long (*)())ptr;
75- else
76- {
77- CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sysinfo: %s\n", dlerror ());
78- err = COL_ERROR_UTIL_INIT;
79- }
80-
81 ptr = dlsym (libc, "clearenv");
82 if (ptr)
83 __collector_util_funcs.clearenv = (int(*)())ptr;
84diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c
85index 66844bc1337..c81ae1a2272 100644
86--- a/gprofng/libcollector/linetrace.c
87+++ b/gprofng/libcollector/linetrace.c
88@@ -1527,7 +1527,7 @@ DCL_FUNC_VER (DCL_POSIX_SPAWNP, posix_spawnp_2_2, posix_spawnp@GLIBC_2.2)
89 DCL_POSIX_SPAWNP (posix_spawnp)
90
91 /*------------------------------------------------------------- system */
92-int system () __attribute__ ((weak, alias ("__collector_system")));
93+int system (const char *cmd) __attribute__ ((weak, alias ("__collector_system")));
94
95 int
96 __collector_system (const char *cmd)
97@@ -1582,10 +1582,10 @@ DCL_FUNC_VER (DCL_POPEN, popen_2_0, popen@GLIBC_2.0)
98 DCL_POPEN (popen)
99
100 /*------------------------------------------------------------- grantpt */
101-int grantpt () __attribute__ ((weak, alias ("__collector_grantpt")));
102+int grantpt (int fildes) __attribute__ ((weak, alias ("__collector_grantpt")));
103
104 int
105-__collector_grantpt (const int fildes)
106+__collector_grantpt (int fildes)
107 {
108 if (NULL_PTR (grantpt))
109 init_lineage_intf ();
110@@ -1607,10 +1607,10 @@ __collector_grantpt (const int fildes)
111 }
112
113 /*------------------------------------------------------------- ptsname */
114-char *ptsname () __attribute__ ((weak, alias ("__collector_ptsname")));
115+char *ptsname (int fildes) __attribute__ ((weak, alias ("__collector_ptsname")));
116
117 char *
118-__collector_ptsname (const int fildes)
119+__collector_ptsname (int fildes)
120 {
121 if (NULL_PTR (ptsname))
122 init_lineage_intf ();
123diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h
124index fd888cd58dd..6640f12fa3c 100644
125--- a/gprofng/src/collector_module.h
126+++ b/gprofng/src/collector_module.h
127@@ -107,7 +107,6 @@ typedef struct CollectorUtilFuncs
128 int (*symlink)(const char *s1, const char *s2);
129 int (*syscall)(int number, ...);
130 long (*sysconf)(int name);
131- long (*sysinfo)(int command, char *buf, long count);
132 time_t (*time)(time_t *tloc);
133 int (*unsetenv)(const char *name);
134 int (*vsnprintf)(char *str, size_t size, const char *format, ...);
135diff --git a/gprofng/testsuite/gprofng.display/mttest/mttest.c b/gprofng/testsuite/gprofng.display/mttest/mttest.c
136index e0835c833e5..3db5b8d8e86 100644
137--- a/gprofng/testsuite/gprofng.display/mttest/mttest.c
138+++ b/gprofng/testsuite/gprofng.display/mttest/mttest.c
139@@ -171,7 +171,7 @@ void computeJ (workStruct_t *x);
140 void computeK (workStruct_t *x);
141 void addone (workCtr_t *x);
142 void init_arrays (int strat);
143-void dump_arrays ();
144+void dump_arrays (hrtime_t real, hrtime_t cpu, int case_index);
145 void *do_work (void *v);
146 void thread_work ();
147 void nothreads (Workblk *array, struct scripttab *k);
148diff --git a/gprofng/testsuite/gprofng.display/synprog/endcases.c b/gprofng/testsuite/gprofng.display/synprog/endcases.c
149index a6a1389658a..6f1c83b6859 100644
150--- a/gprofng/testsuite/gprofng.display/synprog/endcases.c
151+++ b/gprofng/testsuite/gprofng.display/synprog/endcases.c
152@@ -40,8 +40,8 @@ static void s_inline_code (int);
153 void ext_inline_code (int);
154
155 #ifndef NO_INLINE
156-void xinline_code () __attribute__ ((always_inline));
157-void s_inline_code () __attribute__ ((always_inline));
158+void xinline_code (int) __attribute__ ((always_inline));
159+void s_inline_code (int) __attribute__ ((always_inline));
160 #endif
161
162 #include "inc_inline.h"
163diff --git a/gprofng/testsuite/gprofng.display/synprog/inc_inline.h b/gprofng/testsuite/gprofng.display/synprog/inc_inline.h
164index da42563c828..6600eacb66d 100644
165--- a/gprofng/testsuite/gprofng.display/synprog/inc_inline.h
166+++ b/gprofng/testsuite/gprofng.display/synprog/inc_inline.h
167@@ -19,7 +19,7 @@
168 MA 02110-1301, USA. */
169
170 #ifndef NO_INLINE
171-void ext_inline_code() __attribute__ ((always_inline));
172+void ext_inline_code(int) __attribute__ ((always_inline));
173 #endif
174
175 void
176diff --git a/gprofng/testsuite/gprofng.display/synprog/synprog.c b/gprofng/testsuite/gprofng.display/synprog/synprog.c
177index cf1bc5b0909..05920dc7419 100644
178--- a/gprofng/testsuite/gprofng.display/synprog/synprog.c
179+++ b/gprofng/testsuite/gprofng.display/synprog/synprog.c
180@@ -528,14 +528,14 @@ reapchildren ()
181 int
182 doabort (int k)
183 {
184- char *nullptr = NULL;
185+ char *p = NULL;
186 char c;
187
188 /* Log the event */
189 wlog ("start of doabort", NULL);
190
191 /* and dereference a NULL */
192- c = *nullptr;
193+ c = *p;
194
195 /* this should never be reached */
196 return (int) c;