https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82435

            Bug ID: 82435
           Summary: new __attribute__((alias)) warning gets in the way
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnd at linaro dot org
  Target Milestone: ---

gcc-8 started warning about function aliases that have a non-matching
prototype. This seems rather useful in general, but it causes tons of warnings
in the Linux kernel, where we rely on abusing those aliases for system call
entry points, in order to sanitze the arguments passed from user space in
registers, see 
http://elixir.free-electrons.com/linux/v4.13/source/include/linux/syscalls.h#L84

In file included from /git/arm-soc/kernel/sysctl_binary.c:6:0:
/git/arm-soc/include/linux/syscalls.h:211:18: error: 'sys_sysctl' alias between
functions of incompatible types 'long int(struct __sysctl_args *)' and 'long
int(long int)' [-Werror=attributes]
  asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
                  ^~~
/git/arm-soc/include/linux/syscalls.h:207:2: note: in expansion of macro
'__SYSCALL_DEFINEx'
  __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
  ^~~~~~~~~~~~~~~~~
/git/arm-soc/include/linux/syscalls.h:196:36: note: in expansion of macro
'SYSCALL_DEFINEx'
 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
                                    ^~~~~~~~~~~~~~~
/git/arm-soc/kernel/sysctl_binary.c:1418:1: note: in expansion of macro
'SYSCALL_DEFINE1'
 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
 ^~~~~~~~~~~~~~~
/git/arm-soc/include/linux/syscalls.h:215:18: note: aliased declaration here
  asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
                  ^~~
/git/arm-soc/include/linux/syscalls.h:207:2: note: in expansion of macro
'__SYSCALL_DEFINEx'
  __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
  ^~~~~~~~~~~~~~~~~
/git/arm-soc/include/linux/syscalls.h:196:36: note: in expansion of macro
'SYSCALL_DEFINEx'
 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
                                    ^~~~~~~~~~~~~~~
/git/arm-soc/kernel/sysctl_binary.c:1418:1: note: in expansion of macro
'SYSCALL_DEFINE1'
 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
 ^~~~~~~~~~~~~~~

I have not found a way to disable this warning without also disabling all other
warnings about attributes. Ideally we'd have another attribute that lets us
keep on using the existing kernel code with macro to pick the right attributes
based on the gcc version. Alternatively, a separate diagnostic flag to turn off
the warning about incompatible aliases globally would also work.

Reply via email to