Re: Fw: Possible missed optimization opportunity with const?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Toshi Morita <tm314159@xxxxxxxxx> writes:

> what is the correct way to define a pointer to a hardware
> register at 0x1234 which contains immutable data?

It seems "extern const int foo;" with "-Wl,--defsym,foo=0x1234"
almost works, except GCC then uses a RIP-relative reference on
amd64 and that can cause a relocation overflow.

I also tried wrapping the read in an __attribute__((const))
function, which means the return value does not depend on
global memory:

int __attribute__((const)) getfoo() 
{
  return *(const int *) 0x1234;
}

but GCC emitted two reads anyhow.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux