bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin


From: Ken Brown
Subject: bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin
Date: Fri, 19 Jan 2018 15:46:39 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

The next release of Cygwin (2.10.0), expected within the next few weeks, is going to have a new implementation of _FORTIFY_SOURCE guards for many functions, including readlinkat. The implementation is based on that of NetBSD and has the effect of adding code that looks essentially as follows after preprocessing:

ssize_t
__ssp_real_readlinkat (int __dirfd1, const char *__path,
                       char *__buf, size_t __len)
  __asm__("readlinkat");

extern __inline__ __attribute__((__always_inline__, __gnu_inline__))
ssize_t
readlinkat (int __dirfd1, const char *__path, char *__buf,
            size_t __len)
  __asm__("__ssp_protected_readlinkat");

extern __inline__ __attribute__((__always_inline__, __gnu_inline__))
ssize_t
readlinkat (int __dirfd1, const char *__path, char *__buf,
            size_t __len)
{
  if (__builtin_object_size(__buf, 2 > 1) != (size_t)-1
      && __len > __builtin_object_size(__buf, 2 > 1))
    __chk_fail();
  return __ssp_real_readlinkat (__dirfd1, __path, __buf, __len);
}

The occurrence of this code in fileio.c, combined with the use of a pointer to readlinkat in the definition of emacs_readlinkat, leads to an "undefined reference to `__ssp_protected_readlinkat'" linking error.

I'd appreciate some advice on how to fix this. I can think of three possibilities, but maybe there's something better:

1. Add "#define _FORTIFY_SOURCE 0' at the top of fileio.c (Cygwin only).

2. Pretend like Cygwin doesn't have readlinkat. Then gnulib will create its own definition, which will be found by the linker in libegnu.a.

3. Ask gnulib to come up with a fix.

Thanks in advance for any advice.

Ken





reply via email to

[Prev in Thread] Current Thread [Next in Thread]