1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Extend local PLT reference check

On x86, linker in binutils 2.26 and newer consolidates R_*_JUMP_SLOT with
R_*_GLOB_DAT relocation against the same symbol.  This patch extends
local PLT reference check to support alternate relocations.

	[BZ #18078]
	* scripts/check-localplt.awk: Support alternate relocations.
	* scripts/localplt.awk: Also check relocations in DT_RELA/DT_REL
	sections.
	* sysdeps/unix/sysv/linux/i386/localplt.data: Mark free and
	malloc entries with + REL R_386_GLOB_DAT.
	* sysdeps/x86_64/localplt.data: New file.
This commit is contained in:
H.J. Lu
2015-07-29 11:57:54 -07:00
parent febce2ac5f
commit 9637d8a253
6 changed files with 127 additions and 19 deletions

View File

@ -13,6 +13,8 @@ FILENAME != lastfile {
}
lastfile = FILENAME;
jmprel_offset = 0;
rela_offset = 0;
rel_offset = 0;
delete section_offset_by_address;
}
@ -43,6 +45,30 @@ in_relocs && relocs_offset == jmprel_offset && NF >= 5 {
}
}
in_relocs && relocs_offset == rela_offset && NF >= 5 {
# Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
# value, but rather as the resolver symbol followed by ().
if ($4 ~ /\(\)/) {
print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3
} else {
symval = strtonum("0x" $4);
if (symval != 0)
print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3
}
}
in_relocs && relocs_offset == rel_offset && NF >= 5 {
# Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
# value, but rather as the resolver symbol followed by ().
if ($4 ~ /\(\)/) {
print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3
} else {
symval = strtonum("0x" $4);
if (symval != 0)
print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3
}
}
in_relocs { next }
$1 == "Relocation" && $2 == "section" && $5 == "offset" {
@ -62,4 +88,25 @@ $2 == "(JMPREL)" {
next
}
$2 == "(RELA)" {
rela_addr = strtonum($3);
if (rela_addr in section_offset_by_address) {
rela_offset = section_offset_by_address[rela_addr];
} else {
print FILENAME ": *** DT_RELA does not match any section's address";
result = 2;
}
next
}
$2 == "(REL)" {
rel_addr = strtonum($3);
if (rel_addr in section_offset_by_address) {
rel_offset = section_offset_by_address[rel_addr];
} else {
print FILENAME ": *** DT_REL does not match any section's address";
result = 2;
}
next
}
END { exit(result) }