diff mbox series

[22/27] kbuild: generate a list of objects in vmlinux

Message ID 20220424190811.1678416-23-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series kbuild: yet another series of cleanups (modpost and LTO) | expand

Commit Message

Masahiro Yamada April 24, 2022, 7:08 p.m. UTC
A *.mod file lists the member objects of a module, but vmlinux does
not have such a file to list out all the member objects.

Generate this list to allow modpost to know all the member objects.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/link-vmlinux.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Nicolas Schier April 27, 2022, 8:14 p.m. UTC | #1
On Mon 25 Apr 2022 04:08:06 GMT Masahiro Yamada wrote:
> A *.mod file lists the member objects of a module, but vmlinux does
> not have such a file to list out all the member objects.
> 
> Generate this list to allow modpost to know all the member objects.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/link-vmlinux.sh | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 20f44504a644..d2c193f82004 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -310,7 +310,7 @@ cleanup()
>  	rm -f vmlinux
>  	rm -f vmlinux.map
>  	rm -f vmlinux.o
> -	rm -f .vmlinux.d
> +	rm -f .vmlinux*

Wouldn't it be safer to keep the removal of .vmlinux.d for some time 
and just add .vmlinux.objs?  Somehow I do not like the wildcard here.

>  }
>  
>  # Use "make V=1" to debug this script
> @@ -342,6 +342,19 @@ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
>  modpost_link vmlinux.o
>  objtool_link vmlinux.o
>  
> +# Generate the list of objects in vmlinux
> +rm -f .vmlinux.objs
> +for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
> +	case ${f} in
> +	*.a)
> +		${AR} t ${f} >> .vmlinux.objs
> +		;;
> +	*)
> +		echo ${f} >> .vmlinux.objs
> +		;;
> +	esac
> +done

just some bike shedding comment:  I would have left out the 'rm -f 
.vmlinux.objs' and moved the redirection to the end of the for loop:

for f in ...
    ...
    ${AR}
    echo
done > .vmlinux.objs

but it probably not worth.

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

> +
>  # modpost vmlinux.o to check for section mismatches
>  ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
>  
> -- 
> 2.32.0
Masahiro Yamada April 28, 2022, 4:49 a.m. UTC | #2
On Thu, Apr 28, 2022 at 11:56 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Mon 25 Apr 2022 04:08:06 GMT Masahiro Yamada wrote:
> > A *.mod file lists the member objects of a module, but vmlinux does
> > not have such a file to list out all the member objects.
> >
> > Generate this list to allow modpost to know all the member objects.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/link-vmlinux.sh | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> > index 20f44504a644..d2c193f82004 100755
> > --- a/scripts/link-vmlinux.sh
> > +++ b/scripts/link-vmlinux.sh
> > @@ -310,7 +310,7 @@ cleanup()
> >       rm -f vmlinux
> >       rm -f vmlinux.map
> >       rm -f vmlinux.o
> > -     rm -f .vmlinux.d
> > +     rm -f .vmlinux*
>
> Wouldn't it be safer to keep the removal of .vmlinux.d for some time
> and just add .vmlinux.objs?  Somehow I do not like the wildcard here.

OK, will change in v2.


> >  }
> >
> >  # Use "make V=1" to debug this script
> > @@ -342,6 +342,19 @@ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
> >  modpost_link vmlinux.o
> >  objtool_link vmlinux.o
> >
> > +# Generate the list of objects in vmlinux
> > +rm -f .vmlinux.objs
> > +for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
> > +     case ${f} in
> > +     *.a)
> > +             ${AR} t ${f} >> .vmlinux.objs
> > +             ;;
> > +     *)
> > +             echo ${f} >> .vmlinux.objs
> > +             ;;
> > +     esac
> > +done
>
> just some bike shedding comment:  I would have left out the 'rm -f
> .vmlinux.objs' and moved the redirection to the end of the for loop:
>
> for f in ...
>     ...
>     ${AR}
>     echo
> done > .vmlinux.objs

OK, that would shorten the code a little.
Will do in v2.



>
> but it probably not worth.
>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
>
> > +
> >  # modpost vmlinux.o to check for section mismatches
> >  ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
> >
> > --
> > 2.32.0
>
> --
> epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
> ↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
>      -- frykten for herren er opphav til kunnskap --
diff mbox series

Patch

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 20f44504a644..d2c193f82004 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -310,7 +310,7 @@  cleanup()
 	rm -f vmlinux
 	rm -f vmlinux.map
 	rm -f vmlinux.o
-	rm -f .vmlinux.d
+	rm -f .vmlinux*
 }
 
 # Use "make V=1" to debug this script
@@ -342,6 +342,19 @@  ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
 modpost_link vmlinux.o
 objtool_link vmlinux.o
 
+# Generate the list of objects in vmlinux
+rm -f .vmlinux.objs
+for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
+	case ${f} in
+	*.a)
+		${AR} t ${f} >> .vmlinux.objs
+		;;
+	*)
+		echo ${f} >> .vmlinux.objs
+		;;
+	esac
+done
+
 # modpost vmlinux.o to check for section mismatches
 ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1