<div dir="ltr"><div dir="ltr">On Tue, Feb 28, 2023 at 12:33 PM HAGIO KAZUHITO(萩尾 一仁) <<a href="mailto:k-hagio-ab@nec.com">k-hagio-ab@nec.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2023/02/22 16:50, Florian Weimer wrote:<br>
> * HAGIO KAZUHITO(萩尾 一仁):<br>
> <br>
>>> +@@ -123,14 +142,70 @@<br>
>>> + #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)<br>
>>> + #define __bos0(ptr) __builtin_object_size (ptr, 0)<br>
>>> +<br>
>>> ++/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available.  */<br>
>>> ++#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0)                    \<br>
>>> ++                           || __GNUC_PREREQ (12, 0))<br>
>>> ++# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)<br>
>>> ++# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)<br>
>>> ++#else<br>
>>> ++# define __glibc_objsize0(__o) __bos0 (__o)<br>
>>> ++# define __glibc_objsize(__o) __bos (__o)<br>
>>> ++#endif<br>
>>> ++<br>
>><br>
>>> ++#if __USE_FORTIFY_LEVEL > 0<br>
>><br>
>> I could not find this line in the latest GDB source and the related<br>
>> patches.  What is this for?<br>
> <br>
> We need to sync this again with gnulib/GDB.  It was added here, in<br>
> glibc, which is the primary source of this file:<br>
<br>
I see, thanks.<br>
<br>
> <br>
> commit 2337e04e21ba6040926ec871e403533f77043c40<br>
> Author: Siddhesh Poyarekar <<a href="mailto:siddhesh@sourceware.org" target="_blank">siddhesh@sourceware.org</a>><br>
> Date:   Thu Feb 2 07:49:02 2023 -0500<br>
> <br>
>      cdefs: Limit definition of fortification macros<br>
>      <br>
>      Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL ><br>
>      0.  This has the effect of not defining these macros on older C90<br>
>      compilers that do not have support for variable length argument lists.<br>
>      <br>
>      Also trim off the trailing backslashes from the definition of<br>
>      __glibc_fortify and __glibc_fortify_n macros.<br>
>      <br>
>      Signed-off-by: Siddhesh Poyarekar <<a href="mailto:siddhesh@sourceware.org" target="_blank">siddhesh@sourceware.org</a>><br>
>      Reviewed-by: Florian Weimer <<a href="mailto:fweimer@redhat.com" target="_blank">fweimer@redhat.com</a>><br>
> <br>
> I should have made a note that this is coming from the ultimate upstream<br>
> sources.<br>
> <br>
> I raised the issue of <sys/cdefs.h> syncing here:<br>
> <br>
>    Updating <sys/cdefs.h> in glibc and gnulib<br>
>    <<a href="https://sourceware.org/pipermail/libc-alpha/2023-February/145758.html" rel="noreferrer" target="_blank">https://sourceware.org/pipermail/libc-alpha/2023-February/145758.html</a>><br>
> <br>
>>> +@@ -134,6 +136,7 @@ typedef int (*_bashfunc)(const char *, ...);<br>
>>> + #else<br>
>>> + typedef int (*_bashfunc)();<br>
>>> + #endif<br>
>>> ++#include <stdlib.h><br>
>>> + main()<br>
>><br>
>> The GDB patch b4f26d541aa7 ("Import GNU Readline 8.1") has the<br>
>> following:<br>
>><br>
>> @@ -134,6 +138,8 @@ typedef int (*_bashfunc)(const char *, ...);<br>
>>    #else<br>
>>    typedef int (*_bashfunc)();<br>
>>    #endif<br>
>> +#include <stdlib.h><br>
>> +int<br>
>>    main()<br>
>>    {<br>
>>    _bashfunc pf;<br>
>><br>
>> Isn't this "int" needed?<br>
> <br>
> It is, but this part is not actually used (the file is more of a macro<br>
> library for bash, I guess, and the use in readline is merely an<br>
> afterthought).<br>
> <br>
> The problem is that the upstream patch does not really apply to the GDB<br>
> 10.2 sources.  None of this work is really forward-looking, given that<br>
> crash will eventually have to import a newer GDB version.<br>
<br>
True, but there is no plan to update the embedded GDB for now and it<br>
would be better to sync with the upstream code just in case, so I've<br>
updated some hunks like so.  Does the attached patch work for you?<br>
<br>
Lianbo, I've changed the diff headers as you said, could you check<br>
and test this?<br>
<br></blockquote><div><br></div><div>Yes. I'm testing the patch this week.</div><div><br></div><div><div>Thank you, Kazu and Florian.</div><div><br></div></div><div>Lianbo</div></div></div>