diff mbox series

[v1,3/4] elf: move elf_ops.h into include/elf/ and rename

Message ID 20190910193408.28917-4-alex.bennee@linaro.org
State New
Headers show
Series ELF and (macro) safety | expand

Commit Message

Alex Bennée Sept. 10, 2019, 7:34 p.m. UTC
Lets keep all the Elf manipulation bits together. Also rename the file
to better reflect how it is used and add a little header to the file.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 hw/core/loader.c                            | 4 ++--
 include/{hw/elf_ops.h => elf/elf_ops.inc.h} | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
 rename include/{hw/elf_ops.h => elf/elf_ops.inc.h} (98%)

-- 
2.20.1

Comments

Alex Bennée Sept. 11, 2019, 8:20 a.m. UTC | #1
Alex Bennée <alex.bennee@linaro.org> writes:

> Lets keep all the Elf manipulation bits together. Also rename the file

> to better reflect how it is used and add a little header to the file.

>

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  hw/core/loader.c                            | 4 ++--


It is arguable this could be a private header in hw/core as it is only
included in one place.

>  include/{hw/elf_ops.h => elf/elf_ops.inc.h} | 9 +++++++++

>  2 files changed, 11 insertions(+), 2 deletions(-)

>  rename include/{hw/elf_ops.h => elf/elf_ops.inc.h} (98%)

>

> diff --git a/hw/core/loader.c b/hw/core/loader.c

> index e0c6563e643..886179a4947 100644

> --- a/hw/core/loader.c

> +++ b/hw/core/loader.c

> @@ -302,7 +302,7 @@ static void *load_at(int fd, off_t offset, size_t size)

>  #define elf_word        uint32_t

>  #define elf_sword        int32_t

>  #define bswapSZs	bswap32s

> -#include "hw/elf_ops.h"

> +#include "elf/elf_ops.inc.h"

>

>  #undef elfhdr

>  #undef elf_phdr

> @@ -324,7 +324,7 @@ static void *load_at(int fd, off_t offset, size_t size)

>  #define elf_sword        int64_t

>  #define bswapSZs	bswap64s

>  #define SZ		64

> -#include "hw/elf_ops.h"

> +#include "elf/elf_ops.inc.h"

>

>  const char *load_elf_strerror(int error)

>  {

> diff --git a/include/hw/elf_ops.h b/include/elf/elf_ops.inc.h

> similarity index 98%

> rename from include/hw/elf_ops.h

> rename to include/elf/elf_ops.inc.h

> index 1496d7e7536..a820bd821d5 100644

> --- a/include/hw/elf_ops.h

> +++ b/include/elf/elf_ops.inc.h

> @@ -1,3 +1,12 @@

> +/*

> + * Macro expansions for Elf operations. This is included in a

> + * compilation unit with appropriate definitions for SZ and elf

> + * headers to generate utility functions for reading 32 and 64 bit elf

> + * headers.

> + *

> + * SPDX-License-Identifier: GPL-2.0-or-later

> + */

> +

>  static void glue(bswap_ehdr, SZ)(struct elfhdr *ehdr)

>  {

>      bswap16s(&ehdr->e_type);			/* Object file type */



--
Alex Bennée
Richard Henderson Sept. 14, 2019, 6:16 p.m. UTC | #2
On 9/11/19 4:20 AM, Alex Bennée wrote:
> Alex Bennée <alex.bennee@linaro.org> writes:

> 

>> Lets keep all the Elf manipulation bits together. Also rename the file

>> to better reflect how it is used and add a little header to the file.

>>

>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

>> ---

>>  hw/core/loader.c                            | 4 ++--

> It is arguable this could be a private header in hw/core as it is only

> included in one place.

> 


Let's leave it here.


r~
Laurent Vivier Oct. 21, 2019, 1:56 p.m. UTC | #3
Le 10/09/2019 à 21:34, Alex Bennée a écrit :
> Lets keep all the Elf manipulation bits together. Also rename the file

> to better reflect how it is used and add a little header to the file.

> 

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  hw/core/loader.c                            | 4 ++--

>  include/{hw/elf_ops.h => elf/elf_ops.inc.h} | 9 +++++++++

>  2 files changed, 11 insertions(+), 2 deletions(-)

>  rename include/{hw/elf_ops.h => elf/elf_ops.inc.h} (98%)


So the question is: what the ".inc" reflects for a ".h" file?

Thanks,
Laurent
diff mbox series

Patch

diff --git a/hw/core/loader.c b/hw/core/loader.c
index e0c6563e643..886179a4947 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -302,7 +302,7 @@  static void *load_at(int fd, off_t offset, size_t size)
 #define elf_word        uint32_t
 #define elf_sword        int32_t
 #define bswapSZs	bswap32s
-#include "hw/elf_ops.h"
+#include "elf/elf_ops.inc.h"
 
 #undef elfhdr
 #undef elf_phdr
@@ -324,7 +324,7 @@  static void *load_at(int fd, off_t offset, size_t size)
 #define elf_sword        int64_t
 #define bswapSZs	bswap64s
 #define SZ		64
-#include "hw/elf_ops.h"
+#include "elf/elf_ops.inc.h"
 
 const char *load_elf_strerror(int error)
 {
diff --git a/include/hw/elf_ops.h b/include/elf/elf_ops.inc.h
similarity index 98%
rename from include/hw/elf_ops.h
rename to include/elf/elf_ops.inc.h
index 1496d7e7536..a820bd821d5 100644
--- a/include/hw/elf_ops.h
+++ b/include/elf/elf_ops.inc.h
@@ -1,3 +1,12 @@ 
+/*
+ * Macro expansions for Elf operations. This is included in a
+ * compilation unit with appropriate definitions for SZ and elf
+ * headers to generate utility functions for reading 32 and 64 bit elf
+ * headers.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
 static void glue(bswap_ehdr, SZ)(struct elfhdr *ehdr)
 {
     bswap16s(&ehdr->e_type);			/* Object file type */