Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3980 - umbim "address-of-packed-member" compilation warning/errors #8978

Closed
openwrt-bot opened this issue Aug 14, 2021 · 2 comments
Closed
Labels

Comments

@openwrt-bot
Copy link

openwrt-bot commented Aug 14, 2021

rektide:

Environment: arm ipq806x / netgear r7800, trunk
GCC: 10.x

Trying to compile umbim results in a warning/erorr:

make[3]: Entering directory '/usr/local/src/openwrt/package/network/utils/umbim' mkdir -p /usr/local/src/openwrt/dl SHELL= flock /usr/local/src/openwrt/tmp/.umbim-2019-09-11-184b707d.tar.xz.flock -c ' /usr/local/src/openwrt/scripts/download.pl "/usr/local/src/openwrt/dl" "umbim-201 9-09-11-184b707d.tar.xz" "482ff69144f81fafed99035840f5a24e772472f2df2f3ac0219d6de791ac5835" "" || ( echo "Checking out files from the git repository..."; mkdir -p /us r/local/src/openwrt/tmp/dl && cd /usr/local/src/openwrt/tmp/dl && rm -rf umbim-2019-09-11-184b707d && [ \! -d umbim-2019-09-11-184b707d ] && git clone https://git.openw rt.org/project/umbim.git umbim-2019-09-11-184b707d && (cd umbim-2019-09-11-184b707d && git checkout 184b707ddaa0acee84d02e0ffe599cb8b67782bd && git submodule update --in it --recursive) && echo "Packing checkout..." && export TAR_TIMESTAMP=`cd umbim-2019-09-11-184b707d && git log -1 --format='\''@%ct'\''` && rm -rf umbim-2019-09-11-184b7 07d/.git && tar --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name ${TAR_TIMESTAMP:+--mtime="$TAR_TIMESTAMP"} -c umbim-2019-09-11-184b707d | xz -zc -7e > /usr/local/src/openwrt/tmp/dl/umbim-2019-09-11-184b707d.tar.xz && mv /usr/local/src/openwrt/tmp/dl/umbim-2019-09-11-184b707d.tar.xz /usr/local/src/openwrt/dl/ && rm -rf umbim-2019-09-11-184b707d; ) ' touch /usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d/.prepared_d06039bd652ab99df8802435f3362dc7_6664517399ebbbc92a 37c5bb081b5c53_check . /usr/local/src/openwrt/include/shell.sh; xzcat /usr/local/src/openwrt/dl/umbim-2019-09-11-184b707d.tar.xz | tar -C /usr/local/src/openwrt/build_dir/target-arm_cortex-a 15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d/.. -xf - [ ! -d ./src/ ] || cp -fpR ./src/. /usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d touch /usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d/.prepared_d06039bd652ab99df8802435f3362dc7_6664517399ebbbc92a 37c5bb081b5c53 rm -f /usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d/.configured_* rm -f /usr/local/src/openwrt/staging_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/stamp/.umbim_installed mkdir -p /usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d (cd /usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d; CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -W [1/5] Building C object CMakeFiles/umbim.dir/cli.c.o FAILED: CMakeFiles/umbim.dir/cli.c.o /usr/local/src/openwrt/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-10.3.0_musl_eabi/bin/arm-openwrt-linux-muslgnueabi-gcc -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-va riable -Wno-error=unused-result -mfloat-abi=hard -fmacro-prefix-map=/usr/local/src/openwrt/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/umbim-2019-09-11-184b707d=umbim-2019-09-11-184b707d -Wformat -Werror =format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/usr/local/src/openwrt/staging_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/usr/include -ffunction-sections -fdata-sections -DNDE BUG -Os -ggdb -Wextra -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-unused-parameter -MD -MT CMakeFiles/umbim.dir/cli.c.o -MF CMakeFiles/umbim.dir/cli.c.o.d -o CMakeFiles/umbim.dir/cli.c.o -c cli.c cli.c: In function 'mbim_device_caps_response': cli.c:55:29: error: taking address of packed member of 'struct mbim_basic_connect_device_caps_r' may result in an unaligned pointer value [-Werror=address-of-packed-member] 55 | deviceid = mbim_get_string(&caps->deviceid, buffer); | ^~~~~~~~~~~~~~~ cli.c:56:33: error: taking address of packed member of 'struct mbim_basic_connect_device_caps_r' may result in an unaligned pointer value [-Werror=address-of-packed-member] 56 | firmwareinfo = mbim_get_string(&caps->firmwareinfo, buffer); | ^~~~~~~~~~~~~~~~~~~ cli.c:57:33: error: taking address of packed member of 'struct mbim_basic_connect_device_caps_r' may result in an unaligned pointer value [-Werror=address-of-packed-member] 57 | hardwareinfo = mbim_get_string(&caps->hardwareinfo, buffer); | ^~~~~~~~~~~~~~~~~~~ cli.c: In function 'mbim_home_provider_response': cli.c:111:32: error: taking address of packed member of 'struct mbimprovider' may result in an unaligned pointer value [-Werror=address-of-packed-member] 111 | provider_id = mbim_get_string(&provider->providerid, buffer); | ^~~~~~~~~~~~~~~~~~~~~ cli.c:112:34: error: taking address of packed member of 'struct mbimprovider' may result in an unaligned pointer value [-Werror=address-of-packed-member] 112 | provider_name = mbim_get_string(&provider->providername, buffer); | ^~~~~~~~~~~~~~~~~~~~~~~ cli.c: In function 'mbim_registration_response': cli.c:135:32: error: taking address of packed member of 'struct mbim_basic_connect_register_state_r' may result in an unaligned pointer value [-Werror=address-of-packed-member] 135 | provider_id = mbim_get_string(&state->providerid, buffer); | ^~~~~~~~~~~~~~~~~~ cli.c:136:34: error: taking address of packed member of 'struct mbim_basic_connect_register_state_r' may result in an unaligned pointer value [-Werror=address-of-packed-member] 136 | provider_name = mbim_get_string(&state->providername, buffer); | ^~~~~~~~~~~~~~~~~~~~ cli.c:137:32: error: taking address of packed member of 'struct mbim_basic_connect_register_state_r' may result in an unaligned pointer value [-Werror=address-of-packed-member] 137 | roamingtext = mbim_get_string(&state->roamingtext, buffer); | ^~~~~~~~~~~~~~~~~~~ cli.c: In function 'mbim_subscriber_response': cli.c:171:33: error: taking address of packed member of 'struct mbim_basic_connect_subscriber_ready_status_r' may result in an unaligned pointer value [-Werror=address-of-packed-member]
@openwrt-bot
Copy link
Author

openwrt-bot commented Aug 15, 2021

@openwrt-bot
Copy link
Author

openwrt-bot commented Aug 16, 2021

ldir:

Taking the address (pointer to) a member of a structure is unpredictable. There is no guarantee that the type of objects defined in the structure meet architecture alignment rules. ie. there's no guarantee that the 2 signed ints (32 bit) in the string structure are suitably aligned in memory for native cpu access which may require them at 2 or even 4 byte boundaries.

The truly horrible workaround is to pass pointers to a local version of the 'string' structure which is guaranteed to be suitably aligned by the compiler and then copy in/out to final destination in memory.

A suitable patch attached, which compiles for me but is in no way run-time tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant