This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] i386: Use __glibc_likely/__glibc_likely in dl-machine.h


On Mon, Feb 5, 2018 at 12:23 PM, Zack Weinberg <zackw@panix.com> wrote:
> On Mon, Feb 5, 2018 at 7:28 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> The differences in elf/dl-reloc.os are
>>
>> --- before      2018-02-05 03:53:31.970492246 -0800
>> +++ after       2018-02-05 03:53:49.719902340 -0800
>> @@ -1202,9 +1202,9 @@ _dl_relocate_object:
>>         movl    -60(%ebp), %eax
>>         testl   %eax, %eax
>>         je      .L249
>> -       movl    8(%eax), %eax
>> -       movl    8(%ebx), %esi
>> -       cmpl    %esi, %eax
>> +       movl    8(%eax), %esi
>> +       movl    8(%ebx), %eax
>> +       cmpl    %eax, %esi
>
> Since __glibc_(un)likely just expand back to __builtin_expect, why are
> there any assembly differences at all?

These changes are trigger by

@ -663,7 +662,8 @@ elf_machine_lazy_rel (struct link_map *map,
   /* Check for unexpected PLT reloc type.  */
   if (__glibc_likely (r_type == R_386_JMP_SLOT))
     {
-      if (__builtin_expect (map->l_mach.plt, 0) == 0)
+      /* Prelink has been deprecated.  */
+      if (__glibc_likely (map->l_mach.plt == 0))
   *reloc_addr += l_addr;
       else
   *reloc_addr = (map->l_mach.plt

Although they are equivalent, GCC treats

if (__builtin_expect (map->l_mach.plt, 0) == 0)

slightly differently from

if (__glibc_likely (map->l_mach.plt == 0))

such that the outputs aren't identical.


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]