Re: Potential issue with handling of va_arg()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 31 March 2017 at 14:47, Dibyendu Majumdar <mobile@xxxxxxxxxxxxxxx> wrote:
> I am investigating a failure in this test:
>
> #include <stdarg.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> void error_message(const char *fmt, ...) {
> va_list argp;
> va_start(argp, fmt);
> vfprintf(stdout, fmt, argp);
> va_end(argp);
> }
>
> int main(void)
> {
> error_message("%s\n", "hello world");
> return 0;
> }
>
>
> The linearized output for error_message() is:
>
> rror_message:
> .L0:
> <entry-point>
> store.64    %arg1 -> 0[fmt]
> cast.64     %r2 <- (64) fmt
> load.64     %r3 <- 0[stdout]
> call.32     %r6 <- vfprintf, %r3, %arg1, %r2
> ret
>
> Above seems incorrect to me, as %r2 should be pointing to [8]fmt presumably?
>

I think this might be because the macro __builtin_va_start() is being
defined in sparse but this doesn't match what gets defined by gcc? I
see this in sparse:

#define __builtin_va_start(a,b) ((a) = (__builtin_va_list)(&(b)))

but if I run above code through gcc then preprocessed output says:

__builtin_va_start(argp, fmt);

Thanks and Regards
Dibyendu
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux