Related articles |
---|
[26 earlier articles] |
Re: behavior-preserving optimization in C, was compiler bugs Jan.Vorbrueggen@thomson.net (=?ISO-8859-15?Q?Jan_Vorbr=FCggen?=) (2009-05-22) |
Re: behavior-preserving optimization in C, was compiler bugs gneuner2@comcast.net (George Neuner) (2009-05-24) |
Re: behavior-preserving optimization in C, was compiler bugs DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-05-25) |
Re: behavior-preserving optimization in C, was compiler bugs anton@mips.complang.tuwien.ac.at (2009-05-25) |
Re: behavior-preserving optimization in C, was compiler bugs ian@airs.com (Ian Lance Taylor) (2009-05-25) |
Re: behavior-preserving optimization in C, was compiler bugs gneuner2@comcast.net (George Neuner) (2009-05-25) |
Re: behavior-preserving optimization in C, was compiler bugs DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-05-29) |
Re: behavior-preserving optimization in C, was compiler bugs dave.thompson2@verizon.net (David Thompson) (2009-06-15) |
From: | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 29 May 2009 07:05:56 +0200 |
Organization: | Compilers Central |
References: | 09-04-072 09-04-086 09-05-010 09-05-022 09-05-028 09-05-038 09-05-039 09-05-050 09-05-055 09-05-065 09-05-069 09-05-073 09-05-087 09-05-110 09-05-115 09-05-123 |
Keywords: | C, linker |
Posted-Date: | 31 May 2009 11:42:46 EDT |
George Neuner schrieb:
> With two weak definitions of 'x' and a weak definition of 'garbage',
> the compiler did not allocate any storage in the data segment. The
> linker did not object to having no global data (why should it?) and
> produced an executable that crashed with an illegal address
> reference because the system loader didn't assign any pages to the
> empty data segment.
An allocation is not required, because your code doesn't contain
memory reads from the segment. Nonetheless even an empty segment
should have a valid address at runtime.
> I checked the linker's map file to verify that no storage had been
> allocated for variables.
Did the data segment occur in that list at all?
A zero size were perfectly valid, but no segment definition at all would
be illegal.
IMO there must exist a reason, why the loader cannot patch the stored
'&x' offset with the address of the data segment. Most probably it
could not find the according segment symbol in it's load map, because
the linker failed to emit the *definition* of that segment (symbol),
while *referencing* it in the fixup table.
Otherwise, when the segment (symbol) could be found in the load map,
it would be harmless if it's address were unassigned or
illegal. Patching the '&x' offset with an invalid base address would
end up in garbage in the printf() output, but never in an read access
to that address.
> This happened with 4 different compilers under high optimization.
Again an indication of an buggy linker.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.