Skip to content
Snippets Groups Projects
  • Marek Polacek's avatar
    33ebb0df
    configure: Implement --enable-host-bind-now · 33ebb0df
    Marek Polacek authored
    As promised in the --enable-host-pie patch, this patch adds another
    configure option, --enable-host-bind-now, which adds -z now when linking
    the compiler executables in order to extend hardening.  BIND_NOW with RELRO
    allows the GOT to be marked RO; this prevents GOT modification attacks.
    
    This option does not affect linking of target libraries; you can use
    LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now to enable RELRO/BIND_NOW.
    
    With this patch:
    $ readelf -Wd cc1{,plus,obj,gm2} f951 lto1 cpp  rust1 gnat1 | grep FLAGS
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
    
    c++tools/ChangeLog:
    
    	* configure.ac (--enable-host-bind-now): New check.
    	* configure: Regenerate.
    
    gcc/ChangeLog:
    
    	* configure.ac (--enable-host-bind-now): New check.  Add
    	-Wl,-z,now to LD_PICFLAG if --enable-host-bind-now.
    	* configure: Regenerate.
    	* doc/install.texi: Document --enable-host-bind-now.
    
    lto-plugin/ChangeLog:
    
    	* configure.ac (--enable-host-bind-now): New check.  Link with
    	-z,now.
    	* configure: Regenerate.
    33ebb0df
    History
    configure: Implement --enable-host-bind-now
    Marek Polacek authored
    As promised in the --enable-host-pie patch, this patch adds another
    configure option, --enable-host-bind-now, which adds -z now when linking
    the compiler executables in order to extend hardening.  BIND_NOW with RELRO
    allows the GOT to be marked RO; this prevents GOT modification attacks.
    
    This option does not affect linking of target libraries; you can use
    LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now to enable RELRO/BIND_NOW.
    
    With this patch:
    $ readelf -Wd cc1{,plus,obj,gm2} f951 lto1 cpp  rust1 gnat1 | grep FLAGS
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
     0x000000000000001e (FLAGS)              BIND_NOW
     0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
    
    c++tools/ChangeLog:
    
    	* configure.ac (--enable-host-bind-now): New check.
    	* configure: Regenerate.
    
    gcc/ChangeLog:
    
    	* configure.ac (--enable-host-bind-now): New check.  Add
    	-Wl,-z,now to LD_PICFLAG if --enable-host-bind-now.
    	* configure: Regenerate.
    	* doc/install.texi: Document --enable-host-bind-now.
    
    lto-plugin/ChangeLog:
    
    	* configure.ac (--enable-host-bind-now): New check.  Link with
    	-z,now.
    	* configure: Regenerate.