]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Use weak definitions instead of weak declarations
authorJoshua Oreman <oremanj@rwcr.net>
Thu, 27 May 2010 00:52:44 +0000 (17:52 -0700)
committerMichael Brown <mcb30@ipxe.org>
Thu, 27 May 2010 09:19:14 +0000 (10:19 +0100)
This removes the need for inline safety wrappers, marginally reducing
the size penalty of weak functions, and works around an apparent
binutils bug that causes undefined weak symbols to not actually be
NULL when compiling with -fPIE (as EFI builds do).

A bug in versions of binutils prior to 2.16 (released in 2005) will
cause same-file weak definitions to not work with those
toolchains. Update the README to reflect our new dependency on
binutils >= 2.16.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
12 files changed:
README [deleted file]
src/arch/i386/include/pxe_call.h
src/arch/i386/interface/pxe/pxe_call.c
src/arch/i386/interface/pxeparent/pxeparent_dhcp.c
src/arch/i386/interface/syslinux/comboot_call.c
src/include/compiler.h
src/include/ipxe/dhcp.h
src/include/ipxe/sec80211.h
src/include/usr/autoboot.h
src/net/80211/net80211.c
src/net/udp/dhcp.c
src/usr/autoboot.c

diff --git a/README b/README
deleted file mode 100644 (file)
index 011aa21..0000000
--- a/README
+++ /dev/null
@@ -1,8 +0,0 @@
-iPXE README File
-
-Quick start guide:
-
-   cd src
-   make
-
-For any more detailed instructions, see http://ipxe.org
index e6f6605d30682b2cc84772c9224b4223b28b9004..45af46549532032f1cad09636264753dac939f4d 100644 (file)
@@ -38,24 +38,6 @@ extern void pxe_activate ( struct net_device *netdev );
 extern int pxe_deactivate ( void );
 extern int pxe_start_nbp ( void );
 extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 );
-extern int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
-       __attribute__ (( weak ));
-
-/**
- * Dispatch PXE API call weakly
- *
- * @v ix86             Registers for PXE call
- * @ret present                Zero if the PXE stack is present, nonzero if not
- *
- * A successful return only indicates that the PXE stack was available
- * for dispatching the call; it says nothing about the success of
- * whatever the call asked for.
- */
-static inline int pxe_api_call_weak ( struct i386_all_regs *ix86 )
-{
-       if ( _pxe_api_call_weak != NULL )
-               return _pxe_api_call_weak ( ix86 );
-       return -1;
-}
+extern int pxe_api_call_weak ( struct i386_all_regs *ix86 );
 
 #endif /* _PXE_CALL_H */
index 2b17f70ed9e456ff8ec0bc81aacc863b53b8f63c..f6324bbf638b93c247713cd184fe0ab8ed34d3ac 100644 (file)
@@ -351,7 +351,7 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
  * @v ix86             Registers for PXE call
  * @ret present                Zero (PXE stack present)
  */
-int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
+int pxe_api_call_weak ( struct i386_all_regs *ix86 )
 {
        pxe_api_call ( ix86 );
        return 0;
index 439ebda362245bd8993e089e1586248f3a1478c1..8fe1572f2e0b81fcf39d662cc2d0bb3543e91227 100644 (file)
@@ -29,7 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 /**
  * Present cached DHCP packet if it exists
  */
-void __weak_impl ( get_cached_dhcpack ) ( void ) {
+void get_cached_dhcpack ( void ) {
        struct undi_device *undi;
        struct s_PXENV_GET_CACHED_INFO get_cached_info;
        int rc;
index b1489efd0690643d94e4ec3079550c94cdfb52a3..0c52b28a8b7c8ccf361005ab466b80d2ae6a4774 100644 (file)
@@ -318,6 +318,20 @@ static __asmcall void int21 ( struct i386_all_regs *ix86 ) {
 }
 
 
+/**
+ * Dispatch PXE API call weakly
+ *
+ * @v ix86             Registers for PXE call
+ * @ret present                Zero if the PXE stack is present, nonzero if not
+ *
+ * A successful return only indicates that the PXE stack was available
+ * for dispatching the call; it says nothing about the success of
+ * whatever the call asked for.
+ */
+__weak int pxe_api_call_weak ( struct i386_all_regs *ix86 __unused ) {
+       return -1;
+}
+
 /**
  * SYSLINUX API
  */
index a9067c945331a9fdf7ccfecd24e47e3b301768d0..654eaac226dbabd67e6540ae149cee900b3b6959 100644 (file)
@@ -179,41 +179,12 @@ REQUEST_EXPANDED ( CONFIG_SYMBOL );
 /** Select file identifier for errno.h (if used) */
 #define ERRFILE PREFIX_OBJECT ( ERRFILE_ )
 
-/**
- * @defgroup weakmacros Macros to manage weak symbol definitions
- *
- * Weak symbols allow one to reference a function in another file
- * without necessarily requiring that file to be linked in. In their
- * native form, the function will be @c NULL if its file is not linked
- * in; these macros provide an inline wrapper that returns an
- * appropriate error indication or default value.
- *
- * @{
- */
 #ifndef ASSEMBLY
 
-/** Mangle @a name into its weakly-referenced implementation */
-#define __weak_impl( name )   _w_ ## name
-
-/**
- * Declare a weak function with inline safety wrapper
- *
- * @v ret      Return type of weak function
- * @v name     Name of function to expose
- * @v proto    Parenthesized list of arguments with types
- * @v args     Parenthesized list of argument names
- * @v dfl      Value to return if weak function is not available
- */
-#define __weak_decl( ret, name, proto, args, dfl )             \
-        ret __weak_impl( name ) proto __attribute__ (( weak ));        \
-        static inline ret name proto {                         \
-                if ( __weak_impl( name ) )                     \
-                        return __weak_impl( name ) args;       \
-                return dfl;                                    \
-        }
+/** Declare a function as weak (use *before* the definition) */
+#define __weak         __attribute__ (( weak ))
 
 #endif
-/** @} */
 
 /** @defgroup dbg Debugging infrastructure
  * @{
index bbfa293b1e72980e68d2b0caaf6f0644e26b17cf..bbbe73d2c540e48cc33fb6ed54206ab067c43262 100644 (file)
@@ -630,7 +630,7 @@ extern int start_pxebs ( struct job_interface *job, struct net_device *netdev,
  * should look for such a packet and call store_cached_dhcpack() with
  * it if it exists.
  */
-__weak_decl ( void, get_cached_dhcpack, ( void ), (), );
+extern void get_cached_dhcpack ( void );
 
 extern void store_cached_dhcpack ( userptr_t data, size_t len );
 
index 5ac96de1dbff62198d2ff55f90b24a61ea72d55d..59ca3eb85c42b7693232f6951d8f65471b47e60d 100644 (file)
@@ -27,42 +27,11 @@ FILE_LICENCE ( GPL2_OR_LATER );
 /** @file
  *
  * Definitions for general secured-network routines.
- *
- * Any function in this file which may be referenced by code which is
- * not exclusive to encryption-enabled builds (e.g. sec80211_detect(),
- * which is called by net80211_probe_step() to fill the net80211_wlan
- * structure's security fields) must be declared as a weak symbol,
- * using an inline interface similar to that used for
- * sec80211_detect() below. This prevents secure network support from
- * bloating general builds by any more than a few tiny hooks to call
- * crypto functions when crypto structures are non-NULL.
  */
 
-int _sec80211_detect ( struct io_buffer *iob,
-                      enum net80211_security_proto *secprot,
-                      enum net80211_crypto_alg *crypt )
-       __attribute__ (( weak ));
-
-
-/**
- * Inline safety wrapper for _sec80211_detect()
- *
- * @v iob      I/O buffer containing beacon frame
- * @ret secprot        Security handshaking protocol used by network
- * @ret crypt  Cryptosystem used by network
- * @ret rc     Return status code
- *
- * This function transparently calls _sec80211_detect() if the file
- * containing it was compiled in, or returns an error indication of
- * @c -ENOTSUP if not.
- */
-static inline int sec80211_detect ( struct io_buffer *iob,
-                                   enum net80211_security_proto *secprot,
-                                   enum net80211_crypto_alg *crypt ) {
-       if ( _sec80211_detect )
-               return _sec80211_detect ( iob, secprot, crypt );
-       return -ENOTSUP;
-}
+int sec80211_detect ( struct io_buffer *iob,
+                     enum net80211_security_proto *secprot,
+                     enum net80211_crypto_alg *crypt );
 
 int sec80211_detect_ie ( int is_rsn, u8 *start, u8 *end,
                         enum net80211_security_proto *secprot,
index 70c1adfc96ea4f42d859cc9f7ce9176a2eea0082..81b686b546af3f9f1e30c8f38e232f1e9083c780 100644 (file)
@@ -19,7 +19,6 @@ extern int boot_next_server_and_filename ( struct in_addr next_server,
                                           const char *filename );
 extern int boot_root_path ( const char *root_path );
 
-extern int pxe_menu_boot ( struct net_device *netdev )
-       __attribute__ (( weak ));
+extern int pxe_menu_boot ( struct net_device *netdev );
 
 #endif /* _USR_AUTOBOOT_H */
index 0069abaa80677d2f4c479bc7538c8f249363c3a2..8df2c315515aa73292b2644b19183166a7547a96 100644 (file)
@@ -139,6 +139,17 @@ struct net80211_assoc_ctx {
        int times_tried;
 };
 
+/**
+ * Detect secure 802.11 network when security support is not available
+ *
+ * @return -ENOTSUP, always.
+ */
+__weak int sec80211_detect ( struct io_buffer *iob __unused,
+                            enum net80211_security_proto *secprot __unused,
+                            enum net80211_crypto_alg *crypt __unused ) {
+       return -ENOTSUP;
+}
+
 /**
  * @defgroup net80211_netdev Network device interface functions
  * @{
index ac03412d36999449cc19068d4252e0fcd4adf6bf..7850fb4b8fd8dabb87b01d2673c10f3d62f34327 100644 (file)
@@ -1406,6 +1406,11 @@ static struct sockaddr dhcp_peer = {
        .sa_family = AF_INET,
 };
 
+/**
+ * Get cached DHCPACK where none exists
+ */
+__weak void get_cached_dhcpack ( void ) {}
+
 /**
  * Start DHCP state machine on a network device
  *
index acc4efd6a4e995913866aaef799068ff0463283d..48d1fa604c866494481e3f253cf87d70abfca6fa 100644 (file)
@@ -42,6 +42,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
 /** Shutdown flags for exit */
 int shutdown_exit_flags = 0;
 
+/**
+ * Perform PXE menu boot when PXE stack is not available
+ */
+__weak int pxe_menu_boot ( struct net_device *netdev __unused ) {
+       return -ENOTSUP;
+}
+
 /**
  * Identify the boot network device
  *
@@ -155,7 +162,7 @@ static int netboot ( struct net_device *netdev ) {
                               buf, sizeof ( buf ) );
        pxe_discovery_control =
                fetch_uintz_setting ( NULL, &pxe_discovery_control_setting );
-       if ( ( strcmp ( buf, "PXEClient" ) == 0 ) && pxe_menu_boot != NULL &&
+       if ( ( strcmp ( buf, "PXEClient" ) == 0 ) &&
             setting_exists ( NULL, &pxe_boot_menu_setting ) &&
             ( ! ( ( pxe_discovery_control & PXEBS_SKIP ) &&
                   setting_exists ( NULL, &filename_setting ) ) ) ) {