aboutsummaryrefslogtreecommitdiff
path: root/misc
AgeCommit message (Collapse)AuthorFilesLines
2025-01-02mlock, mlock2, munlock: Use __attr_access_none macroSam James1-2/+2
This fixes build failures using GCC 7.5.0 against glibc headers, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118194#c5. Followup to 013106ae677af9836614ace1a01d25b63fa555a7. Reported-by: vvinayag@arm.com
2025-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert191-191/+191
2025-01-01mlock, mlock2, munlock: Tell the compiler we don't dereference the pointerXi Ruoyao1-2/+4
Since https://gcc.gnu.org/r11-959, the compiler emits -Wmaybe-uninitialized if a const pointer to an uninitialized buffer is passed. Tell the compiler we don't dereference the pointer to remove the false alarm. Link: https://gcc.gnu.org/PR118194 Signed-off-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-23Suppress Clang -Wimplicit-fallthrough warningsH.J. Lu1-0/+4
Since Clang doesn't properly handle /* FALLTHROUGH */ in elf/tst-align2.c nor /* fall through */ in misc/tst-tsearch.c tst-align2.c:100:9: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] 100 | case 'A': | ^ tst-align2.c:100:9: note: insert '__attribute__((fallthrough));' to silence this warning 100 | case 'A': | ^ | __attribute__((fallthrough)); tst-align2.c:100:9: note: insert 'break;' to avoid fall-through 100 | case 'A': | ^ | break; suppress them when compiled with Clang. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-23include/sys/cdefs.h: Add __attribute_optimization_barrier__Adhemerval Zanella1-7/+7
Add __attribute_optimization_barrier__ to disable inlining and cloning on a function. For Clang, expand it to __attribute__ ((optnone)) Otherwise, expand it to __attribute__ ((noinline, clone)) Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-22tst-atomic.c: Mark as UNSUPPORTED when compiled with ClangH.J. Lu1-0/+10
Since Clang can't remove the dead statement and issues an error: tst-atomic.c:463:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*&mem)' (aka 'int') 463 | if (catomic_exchange_and_add (&mem, 11) != 2 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add' 213 | __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 214 | mem, value) | ~~~~~~~~~~~ ../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body' 198 | : "=r" (__result), "=m" (*mem) \ | ~~~~~~~~ 199 | : "0" ((int64_t) cast_to_integer (__addval)), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tst-atomic.c:487:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*(&mem))' (aka 'int') 487 | if (catomic_increment_val (&mem) != 3) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/atomic.h:313:38: note: expanded from macro 'catomic_increment_val' 313 | # define catomic_increment_val(mem) (catomic_exchange_and_add ((mem), 1) + 1) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add' 213 | __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 214 | mem, value) | ~~~~~~~~~~~ ../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body' 198 | : "=r" (__result), "=m" (*mem) \ | ~~~~~~~~ 199 | : "0" ((int64_t) cast_to_integer (__addval)), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tst-atomic.c:501:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*(&mem))' (aka 'int') 501 | if (catomic_decrement_val (&mem) != 15) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/atomic.h:340:38: note: expanded from macro 'catomic_decrement_val' 340 | # define catomic_decrement_val(mem) (catomic_exchange_and_add ((mem), -1) - 1) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add' 213 | __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 214 | mem, value) | ~~~~~~~~~~~ ../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body' 198 | : "=r" (__result), "=m" (*mem) \ | ~~~~~~~~ 199 | : "0" ((int64_t) cast_to_integer (__addval)), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mark tst-atomic.c as UNSUPPORTED when compiled with Clang. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-16Use empty initializer to silence GCC 4.9 or olderH.J. Lu1-1/+1
Use empty initializer to silence GCC 4.9 or older: getaddrinfo.c: In function ‘gaih_inet’: getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing-braces] / sizeof (struct gaih_typeproto)] = {0}; ^ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-15Revert "Add braces in initializers for GCC 4.9 or older"H.J. Lu1-1/+1
This reverts commit 8aa2a9e0339215012354f3c4a262edda838134e8. as not all targets need braces.
2024-12-14Add braces in initializers for GCC 4.9 or olderH.J. Lu1-1/+1
Add braces to silence GCC 4.9 or older: getaddrinfo.c: In function ‘gaih_inet’: getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing-braces] / sizeof (struct gaih_typeproto)] = {0}; ^ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-14Return EXIT_UNSUPPORTED if __builtin_mul_overflow unavailableH.J. Lu1-0/+10
Since GCC 4.9 doesn't support __builtin_mul_overflow: tst-fd_to_filename.c: In function ‘check_ranges’: tst-fd_to_filename.c:51:3: error: implicit declaration of function ‘__builtin_mul_overflow’ [-Werror=implicit-function-declaration] while (!__builtin_mul_overflow (power, base, &power)); ^ cc1: all warnings being treated as errors return EXIT_UNSUPPORTED for GCC 4.9 or older. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-05Fix and sort variables in MakefilesH.J. Lu1-45/+45
Fix variables in Makefiles: 1. There is a tab, not a space, between "variable" and =, +=, :=. 2. The last entry doesn't have a trailing \. and sort them. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-11-25Silence most -Wzero-as-null-pointer-constant diagnosticsAlejandro Colomar2-2/+2
Replace 0 by NULL and {0} by {}. Omit a few cases that aren't so trivial to fix. Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059> Link: <https://software.codidact.com/posts/292718/292759#answer-292759> Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-11-20misc: remove extra va_end in error_tail (bug 32233)Andreas Schwab1-1/+0
This is an addendum to commit b7b52b9dec ("error, error_at_line: Add missing va_end calls"), which added the va_end calls in the callers where they belong.
2024-10-10misc: Add support for Linux uio.h RWF_ATOMIC flagAdhemerval Zanella1-1/+4
Linux 6.11 adds the new flag for pwritev2 (commit c34fc6f26ab86d03a2d47446f42b6cd492dfdc56). Checked on x86_64-linux-gnu on 6.11 kernel. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-24misc: Link tst-mkstemp-fuse-parallel with $(shared-thread-library)Florian Weimer1-0/+1
The barrier functions require this on Hurd.
2024-09-21misc: FUSE-based tests for mkstempFlorian Weimer3-0/+422
The tests check that O_EXCL is used properly, that 0600 is used as the mode, that the characters used are as expected, and that the distribution of names generated is reasonably random. The tests run very slowly on some kernel versions, so make them xtests. Reviewed-by: DJ Delorie <dj@redhat.com>
2024-08-01Add mremap testsH.J. Lu3-0/+102
Add tests for MREMAP_MAYMOVE and MREMAP_FIXED. On Linux, also test MREMAP_DONTUNMAP. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-07-01Fix conditionals on mtrace-based tests (bug 31892)Carlos O'Donell1-2/+14
The conditionals for several mtrace-based tests in catgets, elf, libio, malloc, misc, nptl, posix, and stdio-common were incorrect leading to test failures when bootstrapping glibc without perl. The correct conditional for mtrace-based tests requires three checks: first checking for run-built-tests, then build-shared, and lastly that PERL is not equal to "no" (missing perl). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-05-18socket: Use may_alias on sockaddr structs (bug 19622)Florian Weimer1-0/+9
This supports common coding patterns. The GCC C front end before version 7 rejects the may_alias attribute on a struct definition if it was not present in a previous forward declaration, so this attribute can only be conditionally applied. This implements the spirit of the change in Austin Group issue 1641. Suggested-by: Marek Polacek <polacek@redhat.com> Suggested-by: Jakub Jelinek <jakub@redhat.com> Reviewed-by: Sam James <sam@gentoo.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-04-04misc: Add support for Linux uio.h RWF_NOAPPEND flagStafford Horne1-1/+4
In Linux 6.9 a new flag is added to allow for Per-io operations to disable append mode even if a file was opened with the flag O_APPEND. This is done with the new RWF_NOAPPEND flag. This caused two test failures as these tests expected the flag 0x00000020 to be unused. Adding the flag definition now fixes these tests on Linux 6.9 (v6.9-rc1). FAIL: misc/tst-preadvwritev2 FAIL: misc/tst-preadvwritev64v2 This patch adds the flag, adjusts the test and adds details to documentation. Link: https://lore.kernel.org/all/20200831153207.GO3265@brightrain.aerifal.cx/ Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-04-02Always define __USE_TIME_BITS64 when 64 bit time_t is usedAdhemerval Zanella2-3/+3
It was raised on libc-help [1] that some Linux kernel interfaces expect the libc to define __USE_TIME_BITS64 to indicate the time_t size for the kABI. Different than defined by the initial y2038 design document [2], the __USE_TIME_BITS64 is only defined for ABIs that support more than one time_t size (by defining the _TIME_BITS for each module). The 64 bit time_t redirects are now enabled using a different internal define (__USE_TIME64_REDIRECTS). There is no expected change in semantic or code generation. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, and arm-linux-gnueabi [1] https://sourceware.org/pipermail/libc-help/2024-January/006557.html [2] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign Reviewed-by: DJ Delorie <dj@redhat.com>
2024-02-28cdefs: Drop access attribute for _FORTIFY_SOURCE=3 (BZ #31383)Siddhesh Poyarekar1-3/+3
When passed a pointer to a zero-sized struct, the access attribute without the third argument misleads -Wstringop-overflow diagnostics to think that a function is writing 1 byte into the zero-sized structs. The attribute doesn't add that much value in this context, so drop it completely for _FORTIFY_SOURCE=3. Resolves: BZ #31383 Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-27debug: Improve fcntl.h fortify warnings with clangAdhemerval Zanella1-1/+8
It improves open, open64, openat, and openat64. The compile and runtime checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27syslog: Improve fortify with clangAdhemerval Zanella1-2/+12
It improve fortify checks for syslog and vsyslog. The compile and runtime hecks have similar coverage as with GCC. The syslog fortify wrapper calls the va_arg version, since clang does not support __va_arg_pack. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27cdefs.h: Add clang fortify directivesAdhemerval Zanella1-2/+149
For instance, the read wrapper is currently expanded as: extern __inline __attribute__((__always_inline__)) __attribute__((__artificial__)) __attribute__((__warn_unused_result__)) ssize_t read (int __fd, void *__buf, size_t __nbytes) { return __glibc_safe_or_unknown_len (__nbytes, sizeof (char), __glibc_objsize0 (__buf)) ? __read_alias (__fd, __buf, __nbytes) : __glibc_unsafe_len (__nbytes, sizeof (char), __glibc_objsize0 (__buf)) ? __read_chk_warn (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0)) : __read_chk (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0)); } The wrapper relies on __builtin_object_size call lowers to a constant at compile-time and many other operations in the wrapper depends on having a single, known value for parameters. Because this is impossible to have for function parameters, the wrapper depends heavily on inlining to work and While this is an entirely viable approach on GCC, it is not fully reliable on clang. This is because by the time llvm gets to inlining and optimizing, there is a minimal reliable source and type-level information available (more information on a more deep explanation on how to fortify wrapper works on clang [1]). To allow the wrapper to work reliably and with the same functionality as with GCC, clang requires a different approach: * __attribute__((diagnose_if(c, “str”, “warning”))) which is a function level attribute; if the compiler can determine that 'c' is true at compile-time, it will emit a warning with the text 'str1'. If it would be better to emit an error, the wrapper can use "error" instead of "warning". * __attribute__((overloadable)) which is also a function-level attribute; and it allows C++-style overloading to occur on C functions. * __attribute__((pass_object_size(n))) which is a parameter-level attribute; and it makes the compiler evaluate __builtin_object_size(param, n) at each call site of the function that has the parameter, and passes it in as a hidden parameter. This attribute has two side-effects that are key to how FORTIFY works: 1. It can overload solely on pass_object_size (e.g. there are two overloads of foo in void foo(char * __attribute__((pass_object_size(0))) c); void foo(char *); (The one with pass_object_size attribute has precende over the default one). 2. A function with at least one pass_object_size parameter can never have its address taken (and overload resolution respects this). Thus the read wrapper can be implemented as follows, without hindering any fortify coverage compile and runtime: extern __inline __attribute__((__always_inline__)) __attribute__((__artificial__)) __attribute__((__overloadable__)) __attribute__((__warn_unused_result__)) ssize_t read (int __fd, void *const __attribute__((pass_object_size (0))) __buf, size_t __nbytes) __attribute__((__diagnose_if__ ((((__builtin_object_size (__buf, 0)) != -1ULL && (__nbytes) > (__builtin_object_size (__buf, 0)) / (1))), "read called with bigger length than size of the destination buffer", "warning"))) { return (__builtin_object_size (__buf, 0) == (size_t) -1) ? __read_alias (__fd, __buf, __nbytes) : __read_chk (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0)); } To avoid changing the current semantic for GCC, a set of macros is defined to enable the clang required attributes, along with some changes on internal macros to avoid the need to issue the symbol_chk symbols (which are done through the __diagnose_if__ attribute for clang). The read wrapper is simplified as: __fortify_function __attribute_overloadable__ __wur ssize_t read (int __fd, __fortify_clang_overload_arg0 (void *, ,__buf), size_t __nbytes) __fortify_clang_warning_only_if_bos0_lt (__nbytes, __buf, "read called with bigger length than " "size of the destination buffer") { return __glibc_fortify (read, __nbytes, sizeof (char), __glibc_objsize0 (__buf), __fd, __buf, __nbytes); } There is no expected semantic or code change when using GCC. Also, clang does not support __va_arg_pack, so variadic functions are expanded to call va_arg implementations. The error function must not have bodies (address takes are expanded to nonfortified calls), and with the __fortify_function compiler might still create a body with the C++ mangling name (due to the overload attribute). In this case, the function is defined with __fortify_function_error_function macro instead. [1] https://docs.google.com/document/d/1DFfZDICTbL7RqS74wJVIJ-YnjQOj1SaoqfhbgddFYSM/edit Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-01-30syslog: Fix integer overflow in __vsyslog_internal (CVE-2023-6780)Arjun Shankar1-1/+2
__vsyslog_internal calculated a buffer size by adding two integers, but did not first check if the addition would overflow. This commit fixes that. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-01-30syslog: Fix heap buffer overflow in __vsyslog_internal (CVE-2023-6779)Arjun Shankar1-11/+28
__vsyslog_internal used the return value of snprintf/vsnprintf to calculate buffer sizes for memory allocation. If these functions (for any reason) failed and returned -1, the resulting buffer would be too small to hold output. This commit fixes that. All snprintf/vsnprintf calls are checked for negative return values and the function silently returns upon encountering them. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-01-30syslog: Fix heap buffer overflow in __vsyslog_internal (CVE-2023-6246)Arjun Shankar4-15/+82
__vsyslog_internal did not handle a case where printing a SYSLOG_HEADER containing a long program name failed to update the required buffer size, leading to the allocation and overflow of a too-small buffer on the heap. This commit fixes that. It also adds a new regression test that uses glibc.malloc.check. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert186-186/+186
2023-11-22malloc: Use __get_nprocs on arena_get2 (BZ 30945)Adhemerval Zanella1-6/+0
This restore the 2.33 semantic for arena_get2. It was changed by 11a02b035b46 to avoid arena_get2 call malloc (back when __get_nproc was refactored to use an scratch_buffer - 903bc7dcc2acafc). The __get_nproc was refactored over then and now it also avoid to call malloc. The 11a02b035b46 did not take in consideration any performance implication, which should have been discussed properly. The __get_nprocs_sched is still used as a fallback mechanism if procfs and sysfs is not acessible. Checked on x86_64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
2023-07-05misc/bits/syslog.h: Clearly separate declaration from definitionFrédéric Bérat4-10/+40
This allows to include bits/syslog-decl.h in include/sys/syslog.h and therefore be able to create the libc_hidden_builtin_proto (__syslog_chk) prototype. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-07-05misc/bits/select2.h: Clearly separate declaration from definitionsFrédéric Bérat3-4/+34
The __fdelt_chk declaration needs to be available so that libc_hidden_proto can be used while not redefining __FD_ELT. Thus, misc/bits/select-decl.h is created to hold the corresponding prototypes. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-07-05misc/sys/cdefs.h: Create FORTIFY redirects for internal callsFrédéric Bérat1-0/+8
The __REDIRECT* macros are creating aliases which may lead to unwanted PLT entries when fortification is enabled. To prevent these entries, the REDIRECT alias should be set to point to the existing __GI_* aliases. This is done transparently by creating a __REDIRECT_FORTIFY* version of these macros, that can be overwritten internally when necessary. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-07-05Exclude routines from fortificationFrédéric Bérat1-0/+7
Since the _FORTIFY_SOURCE feature uses some routines of Glibc, they need to be excluded from the fortification. On top of that: - some tests explicitly verify that some level of fortification works appropriately, we therefore shouldn't modify the level set for them. - some objects need to be build with optimization disabled, which prevents _FORTIFY_SOURCE to be used for them. Assembler files that implement architecture specific versions of the fortified routines were not excluded from _FORTIFY_SOURCE as there is no C header included that would impact their behavior. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-06-06tests: Replace various function calls with their x variantFrédéric Bérat1-1/+3
With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-06-02Fix all the remaining misspellings -- BZ 25337Paul Pluzhnikov6-7/+7
2023-06-01tests: fix warn unused resultsFrédéric Bérat1-2/+2
With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-18misc: Reformat Makefile.Carlos O'Donell1-3/+3
Reflow Makefile. Sort using updated scripts/sort-makefile-lines.py. Code generation is changed as routines are linked in sorted order as expected. No regressions on x86_64 and i686. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-16misc: Reformat Makefile.Carlos O'Donell1-67/+232
Reflow Makefile. Sort using scripts/sort-makefile-lines.py. Code generation is changed as routines are linked in sorted order as expected. No regressions on x86_64 and i686.
2023-05-10Added Redirects to longdouble error functions [BZ #29033]Sachin Monga4-2/+135
This patch redirects the error functions to the appropriate longdouble variants which enables the compiler to optimize for the abi ieeelongdouble. Signed-off-by: Sachin Monga <smonga@linux.ibm.com>
2023-05-01Mark various cold functions as __COLDSergey Bugaev2-8/+8
GCC docs explicitly list perror () as a good candidate for using __attribute__ ((cold)). So apply __COLD to perror () and similar functions. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230429131223.2507236-3-bugaevc@gmail.com>
2023-04-29cdefs.h: Define __COLDSergey Bugaev1-0/+7
This expands to __attribute__ ((cold)) when supported. It should be used to mark up functions that are invoked rarely. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-04-22misc: Convert daemon () to GNU coding styleSergey Bugaev1-39/+49
This is nicer, and is going to be required for the following changes to reasonably stay within the 79 column limit. No functional change. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Message-Id: <20230419160207.65988-2-bugaevc@gmail.com>
2023-03-27Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functionsAdhemerval Zanella Netto7-8/+13
They are both used by __libc_freeres to free all library malloc allocated resources to help tooling like mtrace or valgrind with memory leak tracking. The current scheme uses assembly markers and linker script entries to consolidate the free routine function pointers in the RELRO segment and to be freed buffers in BSS. This patch changes it to use specific free functions for libc_freeres_ptrs buffers and call the function pointer array directly with call_function_static_weak. It allows the removal of both the internal macros and the linker script sections. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-02-27cdefs.h: fix "__clang_major" typoPaul Eggert1-1/+1
* misc/sys/cdefs.h: Fix misspelling of "__clang_major__". Reviewed-by: Adhemerval Zanella <adhemerval.zan