Control: found -1 16.2.0-1 On 8/7/26 17:48, John David Anglin wrote:
Hi Michael,
Hi! Thank you for your reply.
I suggest you file a gcc bug report. You would need to provide the .i file and compile options. Code simplification is helpful.
Yeah, I'm at it, for a few days already :)
memset is typically provided by libc. One option might be for you to provide a simple implementation of it with your code.
The prob here is that memset *is* provided by the code already. When I naively added another one, it conflicted with the already-provided by the code. But the one provided is not found by the linker. And there are a few more observations here. First, -ffreestanding should ensure there's no calls to memset generated. Second, there are no calls to memset found in the generated disassembly of the functions in question (where the linker complains about missing memset) - though I don't know hppa assembly. 3rd, in objdump -t output, I do see *two* variants of memset symbol - more on this below. And 4th, this seems to be happening only when using -fwhole-program option - which makes the code simplification for the gcc bug report quite a bit more difficult. Now, two variants of memset. Here they are: 00003eec l F .text 00000020 memset.constprop.0 00000000 *UND* 00000000 memset The first is the actual memset provided by the code in question. And the second is the undefined reference. It feels like the prob is .constprop.0 suffix, added with -fwhole-program? Because all other symbols defined by the code have the same .constprop.0 suffix. If my teory is right, we have TWO bugs here. First is -fwhole-program renaming all symbols, so that internal references to them can't be resolved. And second is -ffreestanding which actually does not generate free-standing code.
I don't believe this issue is hppa specific. The -ffreestanding option is handled by common code and the pa backend does not do anything with this option. 00000000 *UND* 00000000 memset
The pa backend also does not issue calls to memset. It doesn't deal with the initialization or layout of structs. But hppa is big endian. This and some other factors affect struct initialization and layout.
Well, whatever it is, so far I only see it on hppa (and hhpa64) - or actually with hppa[64]-linux-gnu-gcc. I'm building qemu, and it uses a lot of other compilers. However, only hppa and x86 builds with -fwhole-program. Without -fwhole-program it seems to work. But I dunno if the resulting binary works. Thanks, /mjt

