mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
68c4956b14
Update
commit ebb191adac
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Feb 9 15:51:22 2022 -0800
x86: Disallow invalid relocation against protected symbol
to allow function pointer reference and make sure that PLT entry isn't
used for function reference due to function pointer reference.
bfd/
PR ld/29087
* elf32-i386.c (elf_i386_scan_relocs): Don't set
pointer_equality_needed nor check non-canonical reference for
function pointer reference.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
ld/
PR ld/29087
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/29087 tests.
* testsuite/ld-x86-64/protected-func-3.c: New file.
42 lines
856 B
C
42 lines
856 B
C
#include <stdio.h>
|
|
|
|
#include "protected-func-1.h"
|
|
|
|
protected_func_type protected_func_1a_ptr = protected_func_1a;
|
|
protected_func_type protected_func_1b_ptr = protected_func_1b;
|
|
|
|
int
|
|
protected_func_1b (void)
|
|
{
|
|
return 3;
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int res = 0;
|
|
|
|
protected_func_1a ();
|
|
protected_func_1b ();
|
|
|
|
/* Check if we get the same address for the protected function symbol. */
|
|
if (protected_func_1a_ptr != protected_func_1a_p ())
|
|
{
|
|
puts ("'protected_func_1a' in main and shared library doesn't have same address");
|
|
res = 1;
|
|
}
|
|
|
|
/* Check if we get the different addresses for the protected function
|
|
symbol. */
|
|
if (protected_func_1b_ptr == protected_func_1b_p ())
|
|
{
|
|
puts ("'protected_func_1b' in main and shared library has same address");
|
|
res = 1;
|
|
}
|
|
|
|
if (!res)
|
|
puts ("PASS");
|
|
|
|
return res;
|
|
}
|