Subject: Re: Bogus variable in ld.elf_so
To: None <email@example.com>
From: Charles Hannum <firstname.lastname@example.org>
Date: 09/05/2002 18:43:08
> I don't understand this in ld.elf_so:
> tmp = (Elf_Addr)(defobj->relocbase + def->st_value);
> if (*where != tmp)
> *where = tmp;
> If *where is not same as tmp, value of tmp is assigned to *where and
> they have same value. If *where is same as tmp, they are still same.
> I can see there lots of unnecessary operations like above. Wouldn't
> it be made simpler like
> *where = (Elf_Addr)(defobj->relocbase + def->st_value);
You'll find that executables, at least, already have *where set to
point to the relevant function, if it's in the executable. Thus, the
conditional store potentially avoids copy-on-write on some number of
pages in each executable.
In practice it doesn't actually help *much*, but it's not entirely
gratuitous. It might help more if the linker actually sorted the PLT
and GOT by whether or not the symbol was defined...