[PATCH v5 02/20] gas: move code for object attribute parsing into obj-elf-attr.c
Matthieu Longo
matthieu.longo@arm.com
Thu Jul 10 11:38:14 GMT 2025
On 2025-07-10 10:48, Richard Earnshaw (lists) wrote:
> On 09/07/2025 11:12, Jan Beulich wrote:
>> On 09.07.2025 12:02, Richard Earnshaw (lists) wrote:
>>> On 07/07/2025 17:49, Matthieu Longo wrote:
>>>> --- /dev/null
>>>> +++ b/gas/config/obj-elf-attr.h
>>>> @@ -0,0 +1,52 @@
>>>> +/* Object attributes parsing.
>>>> + Copyright (C) 2025 Free Software Foundation, Inc.
>>>> +
>>>> + This file is part of GAS, the GNU Assembler.
>>>> +
>>>> + GAS is free software; you can redistribute it and/or modify
>>>> + it under the terms of the GNU General Public License as published by
>>>> + the Free Software Foundation; either version 3, or (at your option)
>>>> + any later version.
>>>> +
>>>> + GAS is distributed in the hope that it will be useful,
>>>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>>> + GNU General Public License for more details.
>>>> +
>>>> + You should have received a copy of the GNU General Public License
>>>> + along with GAS; see the file COPYING. If not, write to the Free
>>>> + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
>>>> + 02110-1301, USA. */
>>>> +
>>>> +#ifndef _OBJ_ELF_ATTR_H
>>>> +#define _OBJ_ELF_ATTR_H
>>>> +
>>>> +#include "as.h"
>>>> +#include "bfd/elf-bfd.h"
>>>> +
>>>> +/* The target supports Object Attributes v1. */
>>>> +#if OBJ_ELF \
>>>
>>> I don't think you need to test OBJ_ELF now, this file is only built when that is true.
>>
>> This being a header file, don't things depend on where the file is included
>> from?
>>
>> Jan
>
> The issue is moot if the TC_OBJ_ATTR definition is moved to the individual tc-<arch>.h files. At that point you probably do need to test OBJ_ELF again as those headers are definitely used by multiple obj formats.
>
> R.
I am a bit confused about what the next step is for me.
As Richard stated it, if I move the definitions into tc-<arch>.h, then I
won't be able to determine whether the target is ELF or not because
OBJ_ELF is defined into obj-elf.h
In this case, it looks to me that I will need to use OBJ_MAYBE_ELF instead.
This seems to be set from gas/configure.ac,
case $fmt in
aout) AC_DEFINE(OBJ_MAYBE_AOUT, 1, [a.out support?]) ;;
coff) AC_DEFINE(OBJ_MAYBE_COFF, 1, [COFF support?]) ;;
ecoff) AC_DEFINE(OBJ_MAYBE_ECOFF, 1, [ECOFF support?]) ;;
elf) AC_DEFINE(OBJ_MAYBE_ELF, 1, [ELF support?]) ;;
generic) AC_DEFINE(OBJ_MAYBE_GENERIC, 1, [generic support?]) ;;
som) AC_DEFINE(OBJ_MAYBE_SOM, 1, [SOM support?]) ;;
esac
but the value is not set in build-dir/gas/config.h when it is compiled
for target aarch64-none-linux-gnu.
/* ELF support? */
/* #undef OBJ_MAYBE_ELF */
Unless you see a solution to detect whether the target is ELF from
tc-<arch>.h, I don't see how I will be able to move the definitions into
tc-<arch>.h
Matthieu
More information about the Binutils
mailing list