On Wed, 1 Jan 2020 at 20:08, Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote: > > On Wed, Jan 01, 2020 at 07:13:45PM +0100, Ard Biesheuvel wrote: > > The GCC documentation mentions that it does not make sense for a > > function annotated as const not to take any arguments, so I'd rather > > avoid it here. > > Where does it say that? I only see it saying it doesn't make sense for > it to return void. > You're right. I looked into this in the past, and I misremembered, and paraphrased it incorrectly. The documentation does mention that const functions are not permitted to read global memory. > Currently if we call 5 EFI services in the same function, it has to > re-evaluate systemtable and is64 for each call, which seems wasteful, > though of course this is not exactly performance-critical code. The alternative would be to use globals with external linkage in a way that is guaranteed not to rely on GOT entries, since we'll end up with absolute addresses that need to be fixed up first. This has caused breakage in the past, and is the reason we use this scheme with globals with static linkage and __pure getters. However, hidden visibility should yield the same results so we should be able to make it work with that instead. However, given the breakage in the past, I don't think it's worth it since the performance gain will be negligible.