Board index » cppbuilder » /Af:nnnn linker switch doesn't work

/Af:nnnn linker switch doesn't work

I just received BCB5 and used it to build a BCB4 project and got the
following fatal linker message: "File alignment size is larger than
section alignment". I have been using the linker switch "/Af:0x1000" in
the BCB4 project file to set file alignment (default:0x200) to be equal
to section alignment (default:0x1000) and this has always worked
perfectly under BCB4. I then added the switch "/Ao:0x1000" and the
project now compiles and links without any problems. However, the
program crashes when run. I removed both switches, let the linker set
it's defaults and the program compiles, links and runs just fine. As far
as I can tell, these linker switches are still supported. Is this
another bug?

Thanks in advance,
- MikeM

 

Re:/Af:nnnn linker switch doesn't work


Quote
> I just received BCB5 and used it to build a BCB4 project and got the
> following fatal linker message: "File alignment size is larger than
> section alignment". I have been using the linker switch "/Af:0x1000" in
> the BCB4 project file to set file alignment (default:0x200) to be equal
> to section alignment (default:0x1000) and this has always worked
> perfectly under BCB4. I then added the switch "/Ao:0x1000" and the
> project now compiles and links without any problems. However, the
> program crashes when run. I removed both switches, let the linker set
> it's defaults and the program compiles, links and runs just fine. As far
> as I can tell, these linker switches are still supported. Is this
> another bug?

First the reason you are getting the error: The PE spec doesn't allow the
file alignment to be larger than the section alignment.

We didn't enforce this in previous versions. The fact that you are seeing
the error now is related to that fix. Still the error is wrong and you have
discovered the workaround.

As for the generated exe crashing... I wasn't able to reproduce that. Care
to share your test case?

--
Anduin Withers
Borland

Re:/Af:nnnn linker switch doesn't work


Quote
> First the reason you are getting the error: The PE spec doesn't allow the
> file alignment to be larger than the section alignment.

> We didn't enforce this in previous versions. The fact that you are seeing
> the error now is related to that fix. Still the error is wrong and you have
> discovered the workaround.

Ok, I assume you mean the fix is still being fixed?

Quote
> As for the generated exe crashing... I wasn't able to reproduce that. Care
> to share your test case?

I inserted the /Ao:0x1000 and /Af:0x1000 switches into the LFLAGS
line of the .BPR files of several of the example apps and they
all crashed throwing an EAccessViolation.

The "...\Examples\Apps\tab" application stopped at the try block
of the following code:

---vcl\Classes.pas----------------------
procedure TThreadList.Add(Item: Pointer);
begin
  LockList;
  try              <-----------------------Stop point
    if (Duplicates = dupAccept) or
       (FList.IndexOf(Item) = -1) then
      FList.Add(Item)
    else if Duplicates = dupError then
      FList.Error(@SDuplicateItem, Integer(Item));
  finally
    UnlockList;
  end;
end;
-----------------------------------------

My application, which is a bit more involved than the "tab" app,
throws an EAccessViolation in the following code:

----vcl\GETMEM.INC-----------------------
function GetBlockDesc: PBlockDesc;
// Get a block descriptor.
// Will return nil for failure.
var
  bd:  PBlockDesc;
  bdb: PBlockDescBlock;
  i:   Integer;
begin
  if blockDescFreeList = nil then begin
    bdb := LocalAlloc(LMEM_FIXED, sizeof(bdb^));
    if bdb = nil then begin
      result := nil;
      exit;
    end;
    bdb.next := blockDescBlockList;
    blockDescBlockList := bdb;
    for i := low(bdb.data) to high(bdb.data) do begin
      bd := @bdb.data[i];
      bd.next := blockDescFreeList;
      blockDescFreeList := bd;
    end;
  end;
  bd := blockDescFreeList;
  blockDescFreeList := bd.next;     <----------Stop point
  result := bd;
end;
----------------------------------------------

Note that without the addition of the switches (without changing the
file alignment), all tested apps compiled and ran fine.

Mike Mallory

Re:/Af:nnnn linker switch doesn't work


I was wrong, my application DOESN'T run properly after compiling
with BCB5. It's an MDI application and the menus aren't merging
properly, but that's a post for the VCL group.

- Mike Mallory

Re:/Af:nnnn linker switch doesn't work


Quote
> Ok, I assume you mean the fix is still being fixed?

Yes. A similar bug had been discovered during the beta and was fixed
unfortunately this one slipped in.

Quote
> I inserted the /Ao:0x1000 and /Af:0x1000 switches into the LFLAGS
> line of the .BPR files of several of the example apps and they
> all crashed throwing an EAccessViolation.

> The "...\Examples\Apps\tab" application stopped at the try block
> of the following code:

I just did the same test... no crash. What OS are you using?

--
Anduin Withers
Borland

Other Threads