[PATCH v2 3/4] elf: Avoid RELATIVE relocs in __tunables_init
Szabolcs Nagy
szabolcs.nagy@arm.com
Fri Jan 8 16:20:25 GMT 2021
With static pie linking pointers in the tunables list need
RELATIVE relocs since the absolute address is not known at link
time. We want to avoid relocations so the static pie self
relocation can be done after tunables are initialized.
This is a quick fix that increases the tunable list size a bit.
---
elf/dl-tunables.c | 2 +-
elf/dl-tunables.h | 4 ++--
scripts/gen-tunables.awk | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 9b4d737fb8..3845b2c04e 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -350,7 +350,7 @@ __tunables_init (char **envp)
/* Skip over tunables that have either been set already or should be
skipped. */
- if (cur->initialized || cur->env_alias == NULL)
+ if (cur->initialized || cur->env_alias[0] == '\0')
continue;
const char *name = cur->env_alias;
diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h
index 518342a300..05997d028a 100644
--- a/elf/dl-tunables.h
+++ b/elf/dl-tunables.h
@@ -38,7 +38,7 @@ __tunables_init (char **unused __attribute__ ((unused)))
/* A tunable. */
struct _tunable
{
- const char *name; /* Internal name of the tunable. */
+ const char name[64]; /* Internal name of the tunable. */
tunable_type_t type; /* Data type of the tunable. */
tunable_val_t val; /* The value. */
bool initialized; /* Flag to indicate that the tunable is
@@ -54,7 +54,7 @@ struct _tunable
target module if the value is
considered unsafe. */
/* Compatibility elements. */
- const char *env_alias; /* The compatibility environment
+ const char env_alias[24]; /* The compatibility environment
variable name. */
};
diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk
index 622199061a..9e7bd24e13 100644
--- a/scripts/gen-tunables.awk
+++ b/scripts/gen-tunables.awk
@@ -57,7 +57,7 @@ $1 == "}" {
maxvals[top_ns,ns,tunable] = max_of[types[top_ns,ns,tunable]]
}
if (!env_alias[top_ns,ns,tunable]) {
- env_alias[top_ns,ns,tunable] = "NULL"
+ env_alias[top_ns,ns,tunable] = "{0}"
}
if (!security_level[top_ns,ns,tunable]) {
security_level[top_ns,ns,tunable] = "SXID_ERASE"
--
2.17.1
More information about the Libc-alpha
mailing list