ld writes to the GOT. The executable segment where .text lives is not written to (it's position independent code in dynamic libraries).
ASLR is not an obstacle -- the same exact code can be mapped into different base addresses in different processes, so they can be backed by the same actual memory.
That’s true on most systems (modern or not), but actually never been true on Windows due to PE/COFF format limitations. But also, that system doesn’t/can’t do effective ASLR because of the binary slide being part of the object file spec.
I can't reconcile this with the code that GCC generates for accessing global variables. There is no additional indirection there, just a constant 0 address that needs to be replaced later.
Assuming the symbol is defined in the library, when the static linker runs (ld -- we're not talking ld.so), it will decide whether the global variable is preemptable or not, that is, if it can be resolved to a symbol outside the dso. Generally, by default it is, though this depends on many things -- visibility attributes, linker scripts, -Bsymbolic, etc. If it is, ld will have the final code reach into the GOT. If not, it can just use instruction (PC) relative offsets.
I'm not sure if you're just trolling, but I'll give the same example I gave before (you can get even wilder simplifications -- called relaxations -- with TLS, since there are 4 levels of generality there). I'm not sure what you meant by "changing isntructions", but in the first case the linker did the fixup indicated by the relocation and in the second reduced the generality of the reference (one less level of indirection by changing mov to lea) because it knew the symbol could not be preempted (more exactly, the R_X86_64_REX_GOTPCRELX relocation allows the linker to do the relaxation if it can determine that it's safe to)
OK, I spent a few additional minutes digging into this. It's been too long since I looked at those mechanisms. Turns out my brain was stuck in pre-PIE world.
Global variables in PIC shared libraries are really weird: the shared library's variable is placed into the main program image data segment and the relocation is happening in the shared library, which means that there is an indirection generated in the library's machine code.
What's been driving up the cost of construction (it's already up to 2000-2400 eur/m2 for a detached house in Portugal) has been mostly cost of materials and labour.
People complain about the regulations, but they also complain about houses that are structurally unsound, unventilated, flammable, badly isolated acoustically and thermally and so on... I don't think going back is the way to go. It's true that sometimes licensing that too long, though.
Not to disrespect you personally, but as someone originally from Russia I'd argue the "cure" of state censorship is worse than the disease of centralisation.
The outcome here is still centralized control, which is why people don't like Cloudflare eating the internet. The Russian government doing it instead is the same outcome.
Yeah, never heard of such a thing. The restrictions are placing the units in common areas of the buildings -- in that case you need permission -- and external walls are usually common parts. Placing them in the façade may have additional restrictions.
But, if anything, energy efficiency standards for new construction are so strict that heat is becoming less of a problem.
> Why would a country like India pay/sacrifice to reduce emissions while western citizens still pollute at much higher levels after reaping all the spoils from historical pollution?
To avoid their country having large regions become uninhabitable?
Even for a giant country like India you control <20% of global population, and you are responsible for much less than 20% of the effect (climate change).
So why would India take more expensive and painful steps than say, the US or EU, or Japan? India both indisputably affects and controls climate change less then the US or EU, so why would they put in completely outsized amounts of effort to fight it?
Air pollution (from smog) in India is already at a "seasonally deadly" level. If you haven't been to India during late autumn, it's hard to imagine how bad it is. Your eyes burn and every breath stings, you literally taste the acrid smog all the time.
India is working hard to get that down. It's a much more tangible and immediate problem there than the thought some parts of the country may become so hot as to be unliveable. Addressing thst, in India, is a side effect / a benefit of cleaning up the air, as much as energy autarky via Solar PV has the benefit of becoming independent of oil imports.
India has coal. Lots of it. It's cheap to them. It doesn't particularly want to use more of it because of the associated air pollution and also because cooling water for thermal power plants competes with drinking water for people in some places.
Personally I think India is rather pragmatic here. Battery banks for scooters in the cities? tick. Buildout of PV? tick. Electric car charging stations? tick. Replacing wood, coal and other dirty cooking fuel by gas? Also tick. India just doesn't bother fighting some internal culture wars about how great fossil fuels or renewables are. They just move ahead more or less silently.
Which leader do you think is more likely to get elected by the populace? The one who tells the destitute Indians they must suffer more, lest their home be lost, or the one who says it’s America’s fault, and that they should pay in MANY ways for what they’re doing to the Indians’ home?
And besides, what do you think they’re going to do? Give up their highly efficient motor bikes? Destroy their personal businesses and starve? How far do you think we could push them? Maybe we could convince them all to just die to make room for our pollution and their nuclear-backed army will agree happily.
I swear half the arguments I see are just completely lacking in regard for the fact that this is happening in the real world, and not a vacuum.
I think there's a middle ground. I like coming up with solutions to problems (mostly technical problems, may even be very low level ones). But I always found writing the code generally tedious. Basically, once I had a good detailed idea of what the implementation would look like, actually executing the plan would bore me.
AI is still not competent enough to come up with good solutions in many things I work on. So, at least so far, AI has made me happier.
There have been type-erasure libraries in c++ for a longish time that allow choosing inline vtables and inline storage. It's definitely been a widely talked about technique for at least 10 years (I see talks about Dyno from 2017).
Well, Rust as well has been around for more than 10 years now. I don't imply Rust invented the approach. Surely academia knew about it decades before. I was rather commenting on how one's mental model of things can change by learning new languages.
If they are so intent on disobeying what makes you they won't just use a VPN or ask someone older to login for them (or any other workaround, depending on the technology)?
I would think it would have to work the same in both since otherwise C code using that behavior would not compile in C++, right?
I am not a C++ expert, but I'm surprised to hear that it is considered UB to access the other member since as far as I can tell a union is just a chunk of memory that can be interpreted differently depending on which union member you access?
So, if you had a union { bool b, char c }, and you set b = false, then I would think that accessing c would predictably give you a value of '\0'.
Granted, you probably shouldn't go around accessing an inactive union member like that, but when people say it's UB they make it sound like it's impossible to guarantee what data will be inside that byte, and it seems to me like that isn't true.
ASLR is not an obstacle -- the same exact code can be mapped into different base addresses in different processes, so they can be backed by the same actual memory.
reply