This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libgloss/warning.h: adjust link_warning construct to modern gcc,gas and ld


Patch checked in. Thanks again.

-- Jeff J.

Hans-Peter Nilsson wrote:
I noticed I didn't get the expected warnings at link time.  I
looked at warning.h, and noticed that __SYMBOL_PREFIX wasn't
used.  I fixed that.

After that, I got a warning, but without the specified message:
/home/hp/cvs_areas/combined/cris-obj/cris-unknown-elf/./newlib/libc.a(makebuf.o):
In function `__smakebuf':^M
/home/hp/cvs_areas/combined/combined/newlib/libc/stdio/makebuf.c:96: warning: ^M

(empty line above; empty message)
So I looked at the assembly code that GCC as of CVS "Fri Jan 14
01:28:39 UTC 2005" generates.  I noticed that the static const
char[] isn't emitted at all!  Well, that's a valid optimization,
since to GCC it's apparently unused!  I fixed that by adding the
"used" attribute to the char[].

After that, I got assembler messages:
isatty.s: Assembler messages:
isatty.s:12: Warning: ignoring changed section type for .gnu.warning._isatty
isatty.s:12: Warning: ignoring changed section attributes for .gnu.warning._isatty

I looked at warning.h again and noticed the
make_section_unallocated hack; emitting a ".section
.gnu.warning.symname" before the char symname[].  That is,
mentioning the section name once before first use, without
attributes and allocation letters, apparently in an attempt to
cause later specifications; specifically allocation
specification, to be ignored.  A brief look at ld history shows
that this was necessary a long long time ago, but now the linker
arranges to throw away .gnu.warning.* sections.  (The
make_section_unallocated hack is benevolent, but nevertheless
it's a redundant hack and the assembler messages may confuse
users.)

I suggest just removing the make_section_unallocated hack, as
per the following patch, which actually works.  (I also
inspected the binary of a program where a linker message had
been emitted to make sure there was no such string.  The local
symbol is there, but not the string contents.)

2005-01-16 Hans-Peter Nilsson <hp@axis.com>

	* libnosys/warning.h (link_warning) [HAVE_GNU_LD and HAVE_ELF]:
	Prefix symbol in section name with __SYMBOL_PREFIX.  Do not use
	__make_section_unallocated.  Mark magic variable as used.

Index: warning.h
===================================================================
RCS file: /cvs/src/src/libgloss/libnosys/warning.h,v
retrieving revision 1.3
diff -c -p -r1.3 warning.h
*** warning.h 15 Jan 2005 00:17:51 -0000 1.3
--- warning.h 16 Jan 2005 18:46:17 -0000
***************
*** 17,25 ****
# ifdef HAVE_SECTION_ATTRIBUTES
# define link_warning(symbol, msg) \
- __make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
! __attribute__ ((section (".gnu.warning." #symbol))) = msg;
# else
# define link_warning(symbol, msg)
# endif
--- 17,25 ----
# ifdef HAVE_SECTION_ATTRIBUTES
# define link_warning(symbol, msg) \
static const char __evoke_link_warning_##symbol[] \
! __attribute__ ((section (".gnu.warning." __SYMBOL_PREFIX #symbol), \
! __used__)) = msg;
# else
# define link_warning(symbol, msg)
# endif


brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]