Create src/utils/bounds_safety.h

The macros in src/utils/bounds_safety.h exist to ensure libwebp
stays portable. This also provides wrappers around common functions like
memcpy/memset/memmove, which are useful as part of the migration. Memcpy
(et al.) wrappers aren't expected to exist forever, and can be removed
after the codebase is fully annotated.

There's some complexity here due to the number of states we need to
support:

1) Off everywhere
2) Building libwebp (some or all) with -fbounds-safety
3) Linking against libwebp that was built with -fbounds-safety
4) Inter-operation with C++

Change-Id: I789f0a94f25b70cab172d5b3f5e6b12de3a34bb4
This commit is contained in:
mxms
2025-07-18 17:26:07 +00:00
parent a7002d2089
commit 9aebd2a64e
2 changed files with 114 additions and 0 deletions

View File

@@ -414,6 +414,7 @@ add_library(webp $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdsp>
$<TARGET_OBJECTS:webpencode> $<TARGET_OBJECTS:webputils>)
if(WEBP_ENABLE_FBOUNDS_SAFETY)
# Enable -fbounds-safety only for webputils for now.
add_definitions(-DWEBP_SUPPORT_FBOUNDS_SAFETY=1)
target_compile_options(webputils PRIVATE -fbounds-safety)
endif()