summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2003-12-29 18:51:16 +0000
committerMartin Schlemmer <azarah@gentoo.org>2003-12-29 18:51:16 +0000
commita763ccb2244cc68561cdf92024acf954d84a03d3 (patch)
tree7183b762722c128c780645b6477ccb6fe5f5ced5 /sys-devel
parentfix $S (diff)
downloadgentoo-2-a763ccb2244cc68561cdf92024acf954d84a03d3.tar.gz
gentoo-2-a763ccb2244cc68561cdf92024acf954d84a03d3.tar.bz2
gentoo-2-a763ccb2244cc68561cdf92024acf954d84a03d3.zip
Merge some tweaks from Solar, and improve on those
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/gcc/files/awk/scanforssp.awk146
-rw-r--r--sys-devel/gcc/files/scan_libgcc_linked_ssp.txt1
2 files changed, 85 insertions, 62 deletions
diff --git a/sys-devel/gcc/files/awk/scanforssp.awk b/sys-devel/gcc/files/awk/scanforssp.awk
index 6d51bc22b812..b6be00059aae 100644
--- a/sys-devel/gcc/files/awk/scanforssp.awk
+++ b/sys-devel/gcc/files/awk/scanforssp.awk
@@ -1,72 +1,68 @@
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author: Martin Schlemmer <azarah@gentoo.org>
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/scanforssp.awk,v 1.2 2003/12/28 22:56:41 azarah Exp $
+# Contributor: Ned Ludd <solar@gentoo.org>
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/scanforssp.awk,v 1.3 2003/12/29 18:51:16 azarah Exp $
+
+# Does not seem to be used in this script.
function printn(string)
{
- system("echo -n \"" string "\"")
+ printf("%s", string)
}
function einfo(string)
{
- system("echo -e \" \\e[32;01m*\\e[0m " string "\"")
+ printf(" %s %s%s", "\033[32;01m*\033[0m", string, "\n")
}
+# Does not seem to be used in this script.
function einfon(string)
{
- system("echo -ne \" \\e[32;01m*\\e[0m " string "\"")
+ printf(" %s %s" , "\033[32;01m*\033[0m", string)
}
function ewarn(string)
{
- system("echo -e \" \\e[33;01m*\\e[0m " string "\"")
+ printf(" %s %s%s" , "\033[33;01m*\033[0m", string, "\n")
}
+# Does not seem to be used in this script.
function ewarnn(string)
{
- system("echo -ne \" \\e[33;01m*\\e[0m " string "\"")
+ printf("%s %s" , "\032[33;01m*\033[0m", string)
}
-
+
function eerror(string)
{
- system("echo -e \" \\e[31;01m*\\e[0m " string "\"")
+ printf(" %s %s%s" , "\033[31;01m*\033[0m", string, "\n")
}
-# assert --- assert that a condition is true. Otherwise exit.
-# This is from the gawk info manual.
-function assert(condition, string)
-{
- if (! condition) {
- printf("%s:%d: assertion failed: %s\n",
- FILENAME, FNR, string) > "/dev/stderr"
- _assert_exit = 1
- exit 1
- }
+ # These are private, else wierd things
+ # might happen ...
+function iself(scan_files, scan_file_pipe, scan_data) {
+ # Can we open() a file and read() 4 bytes?
+ scan_file_pipe = ("head -c 4 " scan_files " 2>/dev/null | tail -c 3")
+ scan_file_pipe | getline scan_data
+ close(scan_file_pipe)
+ return ((scan_data == "ELF") ? 0 : 1)
}
-# system() wrapper that normalize return codes ...
-function dosystem(command, ret)
-{
- ret = 0
-
- ret = system(command)
- if (ret == 0)
- return 1
- else
- return 0
-}
-
-
BEGIN {
-
+ # Do we have etcat ?
+ pipe = ("which etcat 2>/dev/null")
+ if ((((pipe) | getline etcat_data) > 0) && (etcat_data != ""))
+ auto_etcat = 1
+ else
+ auto_etcat = 0
+
DIRCOUNT = 0
# Add the two default library paths
DIRLIST[1] = "/lib"
DIRLIST[2] = "/usr/lib"
# Walk /etc/ld.so.conf line for line and get any library paths
- pipe = "cat /etc/ld.so.conf 2>/dev/null | sort"
+ pipe = ("cat /etc/ld.so.conf 2>/dev/null | sort")
while(((pipe) | getline ldsoconf_data) > 0) {
if (ldsoconf_data !~ /^[[:space:]]*#/) {
@@ -108,11 +104,14 @@ BEGIN {
}
}
- close(pipe)
-
# We have no guarantee that ld.so.conf have more library paths than
# the default, and its better scan files only in /lib and /usr/lib
-# than not at all ...
+# than nothing at all ...
+#
+# exit_val = close(pipe)
+# if (exit_val != 0)
+# print(exit_val " - " ERRNO)
+#
# if (DIRCOUNT == 0) {
# eerror("Could not read from /etc/ld.so.conf!")
# exit 1
@@ -127,18 +126,21 @@ BEGIN {
for (x = 1;x <= count;x++) {
ADDED = 0
-
+
+ # Already added?
for (dnode in DIRLIST)
if (PATHLIST[x] == DIRLIST[dnode])
ADDED = 1
if (ADDED)
continue
-
- DIRLIST[++DIRCOUNT] = PATHLIST[x]
+
+ # Valid? If so, add it ...
+ if (((PATHLIST[x] != "") && (PATHLIST[x] != "/") && (PATHLIST[x] != ".")))
+ DIRLIST[++DIRCOUNT] = PATHLIST[x]
+
}
- FOUND_SSP = 0
GCCLIBPREFIX = "/usr/lib/gcc-lib/"
for (x = 1;x <= DIRCOUNT;x++) {
@@ -146,40 +148,60 @@ BEGIN {
# Do nothing if the target dir is gcc's internal library path
if (DIRLIST[x] ~ GCCLIBPREFIX) continue
- einfo(" Scanning " DIRLIST[x] "...")
+ einfo(" Scanning " ((x <= 9) ? "0"x : x)" of " DIRCOUNT " " DIRLIST[x] "...")
+
+ pipe = ("find " DIRLIST[x] "/ -type f -perm -1 2>/dev/null")
+ while ( (pipe | getline scan_files) > 0) {
- FOUND = 0
+ # Do nothing if the file is located in gcc's internal lib path ...
+ if (scan_files ~ GCCLIBPREFIX) continue
+ # Or if its hardend files ...
+ if (scan_files ~ "/lib/libgcc-3" ) continue
+ # Or not a elf image ...
+ if (iself(scan_files)) continue
- pipe = "find " DIRLIST[x] "/ -type f -perm -1 -maxdepth 9 2>/dev/null"
- while ((((pipe) | getline scan_files) > 0) && (!FOUND)) {
+ scan_file_pipe = ("readelf -s " scan_files " 2>/dev/null")
+ while (((scan_file_pipe) | getline scan_data) > 0) {
+
+ if (scan_data ~ /__guard@GCC/ || scan_data ~ /__guard@@GCC/) {
- # Do nothing if the file is located in gcc's internal lib path
- if (scan_files ~ GCCLIBPREFIX) continue
+ print
- scan_file_pipe = "readelf -s " scan_files " 2>/dev/null"
-# while ((((scan_file_pipe) | getline scan_data) > 0) && (!FOUND)) {
- while (((getline scan_data < (scan_files)) > 0) && (!FOUND)) {
+ # 194: 00000000 32 OBJECT GLOBAL DEFAULT UND __guard@GCC_3.0 (3)
+ # 59: 00008ee0 32 OBJECT GLOBAL DEFAULT 22 __guard@@GCC_3.0
+ split(scan_data, scan_data_nodes)
+ ewarn("Found " scan_data_nodes[8] " in " scan_files "!")
+ print
- if (scan_data ~ /__guard@GCC/) {
+ if (auto_etcat) {
+
+ # Use etcat that comes with gentoolkit if auto_etcat is true.
+ etcat_pipe = ("etcat belongs " scan_files)
+ (etcat_pipe) | getline etcat_belongs
+
+ while(((etcat_pipe) | getline etcat_belongs) > 0)
+ eerror(etcat_belongs != "" ? "Please emerge '>=" etcat_belongs "'": "")
+ close(etcat_pipe)
+ } else {
+
+ eerror("You need to remerge package that above file belongs to!")
+ eerror("To find out what package it is, please emerge gentoolkit,")
+ eerror("and then run:")
+ print
+ print " # etcat belongs " scan_files
+ }
- ewarn(" Found files containing '__guard@GCC'!")
- FOUND = 1
- FOUND_SSP = 1
- break
+ print
+
+ exit(1)
}
}
-
-# close(scan_file_pipe)
- close(scan_files)
+ close(scan_file_pipe)
}
-
close(pipe)
}
- if (FOUND_SSP)
- exit(1)
- else
- exit(0)
+ exit(0)
}
diff --git a/sys-devel/gcc/files/scan_libgcc_linked_ssp.txt b/sys-devel/gcc/files/scan_libgcc_linked_ssp.txt
new file mode 100644
index 000000000000..c1c5ccf243b3
--- /dev/null
+++ b/sys-devel/gcc/files/scan_libgcc_linked_ssp.txt
@@ -0,0 +1 @@
+find / -type f -perm -1 -maxdepth 9 -exec echo -n '__guard at GCC check in: {} ' \; -exec qpkg -f {} \; -exec readelf -s {} \; 2>&1 | grep __guard | grep -B1 '__guard\@GCC'