This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LLVM implemented a recent "libcall optimization" that lowers calls to `sprintf(dest, "%s", str)` where the return value is used to `stpcpy(dest, str) - dest`. This generally avoids the machinery involved in parsing format strings. Calling `sprintf` with overlapping arguments was clarified in ISO C99 and POSIX.1-2001 to be undefined behavior. `stpcpy` is just like `strcpy` except it returns the pointer to the new tail of `dest`. This allows you to chain multiple calls to `stpcpy` in one statement. `stpcpy` was first standardized in POSIX.1-2008. Implement this so that we don't observe linkage failures due to missing symbol definitions for `stpcpy`. Similar to last year's fire drill with: commit 5f074f3 ("lib/string.c: implement a basic bcmp") This optimization was introduced into clang-12. Reported-by: Sami Tolvanen <samitolvanen@google.com> Suggested-by: Arvind Sankar <nivedita@alum.mit.edu> Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Sami Tolvanen <samitolvanen@google.com> Cc: stable@vger.kernel.org Link: https://bugs.llvm.org/show_bug.cgi?id=47162 Link: ClangBuiltLinux/linux#1126 Link: https://man7.org/linux/man-pages/man3/stpcpy.3.html Link: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpcpy.html Link: https://reviews.llvm.org/D85963 Link: https://lore.kernel.org/r/20200815020946.1538085-1-ndesaulniers@google.com Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
- Loading branch information