public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "徐持恒 Xu Chiheng" <chiheng.xu@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, "徐持恒 Xu Chiheng" <chiheng.xu@gmail.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: Re: [PATCH] binutils: partially revert 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8
Date: Fri, 18 Nov 2022 17:37:18 +0800	[thread overview]
Message-ID: <CAPOVtOuN+g3vRAMrL4sdJkPecJ2ge-Er3eLQK6dLFhmh6BsMfg@mail.gmail.com> (raw)
In-Reply-To: <SY4P282MB404738CCE8DD452A63DA4B0B8A069@SY4P282MB4047.AUSP282.PROD.OUTLOOK.COM>

Sorry, but I really think this is a regression.
64 bit linker originally could do relocation on 32 bit object code. It
worked perfectly.
Setting src_mask to 0, ignores the addend value in the section content.

On Fri, Nov 18, 2022 at 4:15 AM 徐持恒 Xu Chiheng <chiheng.xu@gmail.com> wrote:
>
> Sorry, but I really think this is a regession.
> 64 bit linker orginally could do relocation on 32 bit object code. It worked perfectly.
> Setting src_mask to 0, ignore the addend value in the section content.
>
> ________________________________
> From: H.J. Lu <hjl.tools@gmail.com>
> Sent: Friday, November 18, 2022 03:51
> To: 徐持恒 Xu Chiheng <chiheng.xu@gmail.com>
> Cc: binutils@sourceware.org <binutils@sourceware.org>
> Subject: Re: [PATCH] binutils: partially revert 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8
>
> On Thu, Nov 17, 2022 at 11:29 AM 徐持恒 Xu Chiheng <chiheng.xu@gmail.com> wrote:
> >
> > In developing some kernel like program. It start as 32 bit mode, then switch to 64 bit mode. All code are written in C++(only with inline assembly, with no assembly file).
> >
>
> Please compile C++ code to assembly code and add .code32 to assembly
> codes to tell
> assembler to generate 32-bit instructions.
>
> > ________________________________
> > From: H.J. Lu <hjl.tools@gmail.com>
> > Sent: Friday, November 18, 2022 03:11
> > To: 徐持恒 Xu Chiheng <chiheng.xu@gmail.com>
> > Cc: binutils@sourceware.org <binutils@sourceware.org>
> > Subject: Re: [PATCH] binutils: partially revert 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8
> >
> > On Thu, Nov 17, 2022 at 11:01 AM 徐持恒 Xu Chiheng <chiheng.xu@gmail.com> wrote:
> > >
> > > binutils-2.36 and earlier works
> > > binutils-2.37 and later does not work.
> >
> > It worked by accident before.  May I ask why you want to do it this way?
> >
> > > ________________________________
> > > From: H.J. Lu <hjl.tools@gmail.com>
> > > Sent: Friday, November 18, 2022 02:50
> > > To: 徐持恒 Xu Chiheng <chiheng.xu@gmail.com>
> > > Cc: binutils@sourceware.org <binutils@sourceware.org>
> > > Subject: Re: [PATCH] binutils: partially revert 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8
> > >
> > > On Thu, Nov 17, 2022 at 10:28 AM 徐持恒 Xu Chiheng <chiheng.xu@gmail.com> wrote:
> > > >
> > > > No. not using NASM.
> > > >
> > > > using x86_64-elf-g++ -m32 to generate 32 bit code(elf32).
> > > > using x86_64-elf-objcopy to convert it to elf64.
> > > > then link the 32 bit code(elf64) with 64 bit code.
> > > >
> > >
> > > This is an unsupported operation.
> > >
> > > H.J.
> > > >
> > > >
> > > > ________________________________
> > > > From: H.J. Lu <hjl.tools@gmail.com>
> > > > Sent: Friday, November 18, 2022 02:06
> > > > To: 徐持恒 Xu Chiheng <chiheng.xu@gmail.com>
> > > > Cc: binutils@sourceware.org <binutils@sourceware.org>
> > > > Subject: Re: [PATCH] binutils: partially revert 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8
> > > >
> > > > On Thu, Nov 17, 2022 at 9:44 AM 徐持恒 Xu Chiheng via Binutils
> > > > <binutils@sourceware.org> wrote:
> > > > >
> > > > > Phenomenal:  In 32 bit and 64 bit mixed code,  ld can't do relocation
> > > > > for 32 bit code.
> > > > > It is caused by commit 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >   /* src_mask selects the part of the instruction (or data) to be used
> > > > >      in the relocation sum.  If the target relocations don't have an
> > > > >      addend in the reloc, eg. ELF USE_REL, src_mask will normally equal
> > > > >      dst_mask to extract the addend from the section contents.  If
> > > > >      relocations do have an addend in the reloc, eg. ELF USE_RELA, this
> > > > >      field should normally be zero.  Non-zero values for ELF USE_RELA
> > > > >      targets should be viewed with suspicion as normally the value in
> > > > >      the dst_mask part of the section contents should be ignored.  */
> > > > >   bfd_vma src_mask;
> > > > >
> > > > >
> > > > >
> > > > > Author: Jan Beulich <jbeulich@suse.com>  2021-05-07 18:05:12
> > > > > Committer: Jan Beulich <jbeulich@suse.com>  2021-05-07 18:05:12
> > > > > Parent: 98da05bf2698b55b73453480a3fbb92f163d2c7b (x86: don't mix disp
> > > > > and imm processing)
> > > > > Child:  4cf88725da1cb503be04d3237354105ec170bc86 ([gdb/symtab] Fix
> > > > > infinite recursion in dwarf2_cu::get_builder())
> > > > > Branches: master, test0558-01 and many more (41)
> > > > > Follows: gdb-10-branchpoint
> > > > > Precedes: binutils-2_37, gdb-11-branchpoint
> > > > >
> > > > >     x86-64/ELF: clear src_mask for all reloc types
> > > > >
> > > > >     x86-64 uses rela relocations. The comment next to the field's declaration
> > > > >     says "Non-zero values for ELF USE_RELA targets should be viewed with
> > > > >     suspicion ..." And indeed the fields being non-zero causes section
> > > > >     contents to be accumulated into the final relocated values in addition to
> > > > >     the relocations' addends, which is contrary to the ELF spec.
> > > >
> > > > Are you using NASM?
> > > >
> > > > --
> > > > H.J.
> > >
> > >
> > >
> > > --
> > > H.J.
> >
> >
> >
> > --
> > H.J.
>
>
>
> --
> H.J.

  parent reply	other threads:[~2022-11-18  9:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 17:44 徐持恒 Xu Chiheng
2022-11-17 18:06 ` H.J. Lu
     [not found]   ` <SY4P282MB40478D0B56A396B9DF249BBE8A069@SY4P282MB4047.AUSP282.PROD.OUTLOOK.COM>
2022-11-17 18:50     ` H.J. Lu
     [not found]       ` <SY4P282MB40470E7AC17968C86A8731488A069@SY4P282MB4047.AUSP282.PROD.OUTLOOK.COM>
2022-11-17 19:11         ` H.J. Lu
     [not found]           ` <SY4P282MB40478BD7C68830B7DC5705358A069@SY4P282MB4047.AUSP282.PROD.OUTLOOK.COM>
2022-11-17 19:51             ` H.J. Lu
     [not found]               ` <SY4P282MB404738CCE8DD452A63DA4B0B8A069@SY4P282MB4047.AUSP282.PROD.OUTLOOK.COM>
2022-11-18  9:37                 ` 徐持恒 Xu Chiheng [this message]
2022-11-18 10:01                   ` Jan Beulich
2022-11-18 10:24                     ` 徐持恒 Xu Chiheng
2022-11-18 10:34                       ` Jan Beulich
2022-11-18 10:45                         ` 徐持恒 Xu Chiheng
2022-11-18 13:31                           ` Jan Beulich
     [not found]                             ` <CAPOVtOuQ3Xto+uoRVqfyWDuvqO=8XrL64+ujZHY+OsN81Q4E=A@mail.gmail.com>
2022-11-18 14:03                               ` Jan Beulich
     [not found]                               ` <da40ede4-5f91-a35e-dcae-ab222f0d0cdf@suse.com>
     [not found]                                 ` <CAPOVtOsHOzBxx=1bCMgRP-DfWzJu_eS-5UaEj-q_F8p86R-q9g@mail.gmail.com>
2022-11-18 14:09                                   ` Jan Beulich
2022-11-18 14:14                                     ` 徐持恒 Xu Chiheng
2022-11-18 14:35                             ` 徐持恒 Xu Chiheng
2022-11-21  7:53                               ` Jan Beulich
2022-11-21  8:30                                 ` 徐持恒 Xu Chiheng
2022-11-21  8:50                                   ` 徐持恒 Xu Chiheng
2022-11-21  9:02                                   ` Jan Beulich
2022-11-21  9:06                                     ` Jan Beulich
2022-11-21  9:21                                     ` 徐持恒 Xu Chiheng
2022-11-21  9:52                                       ` Jan Beulich
2022-11-21 10:59                                         ` 徐持恒 Xu Chiheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPOVtOuN+g3vRAMrL4sdJkPecJ2ge-Er3eLQK6dLFhmh6BsMfg@mail.gmail.com \
    --to=chiheng.xu@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).