PATCH: nonexec stack for wine libraries
Marcus Meissner
meissner at suse.de
Fri Jan 20 07:15:16 CST 2006
On Fri, Jan 20, 2006 at 01:13:49PM +0100, Marcus Meissner wrote:
> On Fri, Jan 20, 2006 at 11:59:27AM +0100, Marcus Meissner wrote:
> > Hi,
> >
> > This makes our libraries compile marked as not needed an executeable
> > stack.
> >
> > Its not yet fully making it non-x, but its a step.
> >
> > To confirm that behaviour changed, run:
> > readelf -a foo.dll.so|grep GNU_STACK
> >
> > It will change from RWE flags to RW flags.
>
> Next try, reducing it to a platform specific check.
Updated, now also outputs non exec stack assembler for the 16 and 32bit
relay assembler files.
> I can't really test it on anything but Linux, so if it fails
> just add to the case PLATFORM_WINDOWS case.
Ciao, Marcus
Changelog:
Output a .note.GNU-stack section to allow nonexecutable stack.
Index: tools/winebuild/build.h
===================================================================
RCS file: /home/wine/wine/tools/winebuild/build.h,v
retrieving revision 1.87
diff -u -r1.87 build.h
--- tools/winebuild/build.h 19 Dec 2005 09:24:10 -0000 1.87
+++ tools/winebuild/build.h 20 Jan 2006 13:09:04 -0000
@@ -171,6 +171,7 @@
__attribute__ ((__format__ (__printf__, 1, 2)));
extern char *get_temp_file_name( const char *prefix, const char *suffix );
extern void output_standard_file_header( FILE *outfile );
+extern void print_note_GNU_stack( FILE *outfile );
extern FILE *open_input_file( const char *srcdir, const char *name );
extern void close_input_file( FILE *file );
extern void dump_bytes( FILE *outfile, const void *buffer, unsigned int size );
Index: tools/winebuild/relay.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/relay.c,v
retrieving revision 1.54
diff -u -r1.54 relay.c
--- tools/winebuild/relay.c 19 Dec 2005 09:25:32 -0000 1.54
+++ tools/winebuild/relay.c 20 Jan 2006 13:09:04 -0000
@@ -923,6 +923,9 @@
/* File header */
fprintf( outfile, "/* File generated automatically. Do not edit! */\n\n" );
+
+ print_note_GNU_stack( outfile );
+
fprintf( outfile, "\t.text\n" );
fprintf( outfile, "%s:\n\n", asm_name("__wine_spec_thunk_text_16") );
@@ -982,6 +985,7 @@
/* File header */
fprintf( outfile, "/* File generated automatically. Do not edit! */\n\n" );
+ print_note_GNU_stack( outfile );
fprintf( outfile, "\t.text\n" );
fprintf( outfile, "%s:\n\n", asm_name("__wine_spec_thunk_text_32") );
Index: tools/winebuild/utils.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/utils.c,v
retrieving revision 1.40
diff -u -r1.40 utils.c
--- tools/winebuild/utils.c 19 Dec 2005 09:24:10 -0000 1.40
+++ tools/winebuild/utils.c 20 Jan 2006 13:09:04 -0000
@@ -192,6 +192,19 @@
return name;
}
+void print_note_GNU_stack (FILE *outfile )
+{
+ switch (target_platform) {
+ case PLATFORM_WINDOWS: /* Working differently on Windows I guess */
+ break;
+ /* not sure about APPLE or SVR4, but they might use gnu utils */
+ default:
+ fprintf (outfile,".section .note.GNU-stack,\"\", at progbits\n");
+ fprintf (outfile,".previous\n");
+ break;
+ }
+}
+
/* output a standard header for generated files */
void output_standard_file_header( FILE *outfile )
{
@@ -202,6 +215,7 @@
fprintf( outfile, "/* File generated automatically; do not edit! */\n" );
fprintf( outfile,
"/* This file can be copied, modified and distributed without restriction. */\n\n" );
+ print_note_GNU_stack( outfile );
}
/* dump a byte stream into the assembly code */
More information about the wine-patches
mailing list